php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65132 trim does not include non breaking whitespace
Submitted: 2013-06-26 08:19 UTC Modified: 2013-06-26 15:49 UTC
From: daniel at 203core dot se Assigned:
Status: Wont fix Package: Strings related
PHP Version: 5.4.16 OS: FreeBSD 9.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: daniel at 203core dot se
New email:
PHP Version: OS:

 

 [2013-06-26 08:19 UTC] daniel at 203core dot se
Description:
------------
If a line contains a non-breaking white space (\xA0) trim doesnt strip it, it should as its a "space" character

This can easily be bypassed by sending the \xA0 character in the option parameter but it took a while to figure out there was a non-breaking space character in the string

Test script:
---------------
<?php

$string = " \xA0";
echo strlen(trim($string));

Expected result:
----------------
the script should output a length of 0

Actual result:
--------------
The script outputs a length of 1 as trim doesnt strip the non breaking space

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-26 15:49 UTC] aharvey@php.net
-Status: Open +Status: Wont fix -Package: Scripting Engine problem +Package: Strings related
 [2013-06-26 15:49 UTC] aharvey@php.net
There are multibyte encodings which are ASCII compatible where a0 is a valid byte 
in non-space characters, Shift JIS being the most obvious one. There would also 
be the issue that a0 is only part of the non-breaking space character in UTF-8 — 
to trim UTF-8 NBSPs, you'd have to also include c2, which would cause even more 
problems.

As a result, we can't really change this. Closing won't fix.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 13:01:31 2024 UTC