php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77567 \s don't cache a   html decoded
Submitted: 2019-02-04 15:15 UTC Modified: 2019-02-04 16:14 UTC
From: thibaud at 42stores dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 7.2.14 OS: Ubuntu 18.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: thibaud at 42stores dot com
New email:
PHP Version: OS:

 

 [2019-02-04 15:15 UTC] thibaud at 42stores dot com
Description:
------------
---
From manual page: https://php.net/function.html-entity-decode
---

\s meta-character in regular expression don't cache the character resulting of a html_entity_decode of a string containing " " (using utf-8).

Test script:
---------------
var_dump(preg_replace('/\s+/','!',html_entity_decode(' ')));


Expected result:
----------------
string(1) "!"

Actual result:
--------------
string(2) " "

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-02-04 16:14 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2019-02-04 16:14 UTC] nikic@php.net
You are missing the /u modifier, to treat the string as UTF-8 and enable UCP mode:

var_dump(preg_replace('/\s+/u','!',html_entity_decode(' ')));
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 12:01:29 2025 UTC