php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55562 grapheme_substr() returns false if length parameter is to large
Submitted: 2011-09-01 13:19 UTC Modified: 2011-09-04 18:50 UTC
From: thomas at weinert dot info Assigned: stas (profile)
Status: Closed Package: I18N and L10N related
PHP Version: 5.3.8 OS: Windows
Private report: No CVE-ID: None
 [2011-09-01 13:19 UTC] thomas at weinert dot info
Description:
------------
If the input string contains multibyte characters and the length argument is greater then the possible maximum length of the result the function returns false.

Test script:
---------------
<?php
var_dump(
  grapheme_substr('FOK', 1, 20), // expected: OK
  grapheme_substr('한국어', 1, 20) //expected: 국어
);

Expected result:
----------------
string(2) "OK"
string(6) "국어"

Actual result:
--------------
string(2) "OK"
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-04 17:14 UTC] pajoye@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: stas
 [2011-09-04 17:14 UTC] pajoye@php.net
I can confirm this bug, but I'm not sure how to fix it correctly. If I fix the 
related logic, the substr tests then partially fail. This function is cryptic and 
should really deserve some comments about what means each variable name and what 
are their goals...
 [2011-09-04 18:49 UTC] stas@php.net
Automatic comment from SVN on behalf of stas
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=316113
Log: fix bug 55562 - make substr always return rest of the string if length is too long
 [2011-09-04 18:50 UTC] stas@php.net
-Status: Assigned +Status: Closed
 [2011-09-04 18:50 UTC] stas@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

fixed, thanks
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 09:01:32 2024 UTC