From:             sites at hubmed dot org
Operating system: OS X
PHP version:      5.2.6
PHP Bug Type:     DOM XML related
Bug description:  DOMText::splitText doesn't handle multibyte characters

Description:
------------
Using the DOMText function splitText() on a text node containing multibyte
characters results in the node being split at the wrong position.

Reproduce code:
---------------
$text = 'This is an ‘example’ of using DOM splitText';
$start = 30;
$length = 3;

$dom = new DOMDocument('1.0', 'UTF-8');
$node = $dom->createTextNode($text);
$dom->appendChild($node);

print "Text: $node->textContent\n";

print 'Expected (mb_substr): ' . mb_substr($text, $start, $length,
'UTF-8') . "\n";

$matched = $node->splitText($start);
$matched->splitText($length);
print "Actual (splitText): $matched->textContent\n";

Expected result:
----------------
Text: This is an ‘example’ of using DOM splitText
Expected (mb_substr): DOM
Actual (splitText): DOM


Actual result:
--------------
Text: This is an ‘example’ of using DOM splitText
Expected (mb_substr): DOM
Actual (splitText): ing


-- 
Edit bug report at http://bugs.php.net/?id=46335&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=46335&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=46335&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=46335&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=46335&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=46335&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=46335&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=46335&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=46335&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=46335&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=46335&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=46335&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=46335&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=46335&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=46335&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=46335&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=46335&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=46335&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=46335&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=46335&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=46335&r=mysqlcfg

Reply via email to