php / php/php-src

get_html_translation_table() inconsistent results with ENT_XHTML?

Aperta
#11,527 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug Status: Needs Triage
Lingua principale
C
Stelle
40.4k
Fork
8.2k
Merge medio
2g 13h
PR unite (30g)
96

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo le chiamate a get_html_translation_table() riportate nell’issue su una build di PHP supportata, confrontando HTML_SPECIALCHARS e HTML_ENTITIES con ENT_XHTML. Analizza l’implementazione e i test esistenti per questi flags; il lavoro è completo quando la tabella delle specialchars presenta corrispondenze coerenti per le virgolette con la tabella delle entities, inclusa la rappresentazione dell’apostrofo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
php
Ambito
backend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.