php / php/php-src

get_html_translation_table() inconsistent results with ENT_XHTML?

未关闭
#11,527 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Status: Needs Triage
主要语言
C
星标
40.4k
派生
8.2k
平均合并
2 天 15 小时
30 天内合并 PR
103

描述

Description

The following code:

<?php

print_r(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES | ENT_SUBSTITUTE | ENT_XHTML, "UTF-8"));
print_r(get_html_translation_table(HTML_ENTITIES, ENT_QUOTES | ENT_SUBSTITUTE | ENT_XHTML, "UTF-8"));

Resulted in this output:

Array
(
    ["] => &quot;
    [&] => &amp;
    ['] => &apos;
    [<] => &lt;
    [>] => &gt;
)
Array
(
    ["] => &quot;
    [&] => &amp;
    ['] => &#039;
    [<] => &lt;
    [>] => &gt;
    [ ] => &nbsp;
    // ...
    // ...
)

But I expected the specialchars table to be a subset of the entities table. The single quotes in the entities table is substituted using the decimal notation, while it uses the html5 named entity notation in the specialchars table.

PHP Version

PHP 5.4 to PHP 8.2

Operating System

mint/ubuntu 22.04

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,在受支持的 PHP 构建上重现 issue 中的 get_html_translation_table() 调用,并将 HTML_SPECIALCHARS 和 HTML_ENTITIES 与 ENT_XHTML 进行比较。追踪这些 flags 的实现和现有测试;当 specialchars 表中的引号映射与 entities 表保持一致(包括单引号的表示形式)时,即可视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
php
领域
backend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。