ezyang / ezyang/htmlpurifier

PHP 7 weird output

Open
#191 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
3.4k
Forks
361
Avg merge
3d 41m
Merged PRs (30d)
2

Description

Using PHP 7 the output of René & Danny is René & Danny instead of the expected René & Danny. It's a specific character combination, you can test it using the following PHP code:

$msg = ['Testé &', 'Testéé &', 'Testé
& text &','Testéé & text
&','Testééé & text &'];
$pur_config = ['HTML.Allowed' =>
'br,p,strong,ol,ul,li,em,i,u,a[href]','HTML.TargetBlank' => true];
foreach($msg as $val){
 echo $val." - ".\Purify::clean($val, $pur_config)."<br />";
}

This behaviour is only on PHP 7, using the exact same code on PHP 5 the output will be as expected.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided PHP 7 reproduction and trace the Purify::clean entry point, comparing its output with PHP 5 for the listed character combinations. The fix is complete when the PHP 7 output preserves René as Ren&eacute; while still encoding the ampersand as &amp;.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.