From: phpwnd at gmail dot com Operating system: PHP version: 5.4.11 Package: XSLT related Bug Type: Feature/Change Request Bug description:XSLTProcessor::setParameter() should allow both quotes to be used
Description: ------------ XSLTProcessor::setParameter() does not currently allow values that contain both single quotes and double quotes. This appears to be intentional, as per php_xsl_xslt_string_to_xpathexpr() located in ext/xsl/xsltprocessor.c line 119. (https://github.com/php/php-src/blob/master/ext/xsl/xsltprocessor.c#L119) This shortcoming comes from the fact that XPath 1.0 does not provide a mechanism to escape characters, so PHP does not have a straightforward way to express a string that contains both types of quotes. XPath 1.0 does, however, provide a function to concatenate strings. Using concat(), a string composed of the two characters "' can be expressed as concat('"',"'"). concat() takes 2 or more arguments so as long as you alternate the quoting style, you can express a string containing any number of quotes of both types. This is the proposed change: use XPath's concat() function to express strings that contain both types of quotes. Test script: --------------- <?php $xml = new DOMDocument; $xml->loadXML('<X/>'); $xsl = new DOMDocument; $xsl->loadXML('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="text"/><xsl:param name="foo"/><xsl:template match="/"><xsl:value-of select="$foo"/></xsl:template></xsl:stylesheet>'); $xslt = new XSLTProcessor; $xslt->importStylesheet($xsl); $xslt->setParameter('', 'foo', "\"'"); echo $xslt->transformToXml($xml); Expected result: ---------------- "' Actual result: -------------- PHP Warning: XSLTProcessor::transformToXml(): Cannot create XPath expression (string contains both quote and double-quotes) in %s on line %d -- Edit bug report at https://bugs.php.net/bug.php?id=64137&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64137&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64137&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64137&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64137&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64137&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64137&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64137&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64137&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64137&r=support Expected behavior: https://bugs.php.net/fix.php?id=64137&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64137&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64137&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64137&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64137&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64137&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64137&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64137&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64137&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64137&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64137&r=mysqlcfg