Issue Type: Bug Created: 2008-08-27T02:56:00.000+0000 Last Updated: 2008-09-02T10:38:53.000+0000 Status: Resolved Fix version(s): - 1.6.0 (02/Sep/08)
Reporter: Remy Damour (remy215) Assignee: Thomas Weidner (thomas) Tags: - Zend_Translate
Related issues: Attachments:
If you use the following header for xliff files: instead of (i.e. single quotes instead of double quotes for "enconding" attribute value) you end up with the following exception: Fatal error: Uncaught exception 'Zend_Translate_Exception' with message 'XML error: No error at line 0' in /home/remy/my_php/ZendFramework-1.5.3/library/Zend/Translate/Adapter/Xliff.php:97 Stack trace:
My xliff file has been generated by translate-toolkit (part of pootle project), using po2xliff python script. At first I thought that all attribute values had to be wrapped into double quotes (cf. http://bugs.locamotion.org/show_bug.cgi?id=492) but single quotes appear to be legal too (cf. http://www.w3.org/TR/REC-xml/#NT-EncodingDecl).
Error comes from Zend_Translate_Adapter_Xliff->_findEncoding() method which tries to extract xml encoding from xliff file, but expect encoding value to be wrapped using double-quotes: line 195: $encoding = substr($encoding, 0, strpos($encoding, '"'));
One solution could be "$encoding = substr($encoding, 0, min(strpos($encoding, '"'), strpos($encoding, "'")));" since no single quote is to be found in any valid encoding value.
Posted by Remy Damour (remy215) on 2008-08-27T03:05:19.000+0000
Oups! my suggested solution does not work. (one of the two min() arguments may be false and then return 0). The following one works (it detects opening char (" or ') and look for corresponding closing one): [old] $encoding = substr($file, strpos($file, "encoding") + 10); $encoding = substr($encoding, 0, strpos($encoding, '"')); [new] $encoding = substr($file, strpos($file, "encoding") + 9); $encoding = substr($encoding, 1, strpos($encoding, $encoding));
Posted by Thomas Weidner (thomas) on 2008-08-27T11:32:48.000+0000
Fixed with r11088.
PS: Given solution code does not work.
Posted by Remy Damour (remy215) on 2008-08-27T11:35:54.000+0000
thx. I saw it too, I attached a working solution as comment #1 Cheers
Posted by Thomas Weidner (thomas) on 2008-08-27T11:58:05.000+0000
Both of your solutions do not work :-) Look at trunk.. your encoding is ALWAYS empty as you must add an offset of 1 to the strpos in the second line. Otherwise it will be substr() from 1 to 0 which is empty :-)
Posted by Remy Damour (remy215) on 2008-08-27T12:31:08.000+0000
You're 100% right, shame on me :P
I forgot to add "1" as offset on my second strpos.
$encoding = substr($file, strpos($file, "encoding") + 9); $encoding = substr($encoding, 1, strpos($encoding, $encoding, 1));
Thanks for your vigileance :) Remy
Posted by Wil Sinclair (wil) on 2008-09-02T10:38:53.000+0000
Updating for the 1.6.0 release.
Have you found an issue?
See the Overview section for more details.