GNOME Bugzilla – Bug 343079
--stringparam should support all quotes
Last modified: 2021-07-05 10:59:56 UTC
--stringparam should allow string parameters that contain both single quotes and double quotes. XPath strings can contain both; it's just that the current implementation of --stringparam is stupid and complains if the parameter contains both kinds of quotes instead of correctly wrapping the parameter in an XPath string expression. Other information: I suggest the following way of wrapping string parameters; it handles all combinations of quotes correctly at a minor penalty in performance. Replace each single quote in the parameter with the seven-character string ',"'",' . Then add concat('',' at the beginning and ') at the end. (The extra '' at the beginning is needed so that concat gets the required two arguments when the input has no single quotes.) I was using a bash script along the lines of xsltproc --stringparam foo "$1" grab-parameters.xsl dummy.xml as an easy way to make a properly escaped XML file with elements containing given text strings. However, this didn't work if $1 contained both kinds of quotes. My workaround was to implement the technique described above in bash to wrap $1 in an XPath expression and pass the expression using --param. My script now looks like this: apos="'" function pq { echo -n "concat($apos$apos,$apos${1//$apos/$apos,"$apos",$apos}$apos)"; } xsltproc --param foo "$(pq "$1")" grab-parameters.xsl dummy.xml Enjoy the workaround until/unless this bug is fixed.
I happened upon this old report of mine and, out of curiosity, retested it with Fedora's libxslt-1.1.26-1.fc11.x86_64; the problem still exists. Bugzilla doesn't know about version 1.1.26, so I'll mark this 1.1.x.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxslt/-/issues/ Thank you for your understanding and your help.