After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 343079 - --stringparam should support all quotes
--stringparam should support all quotes
Status: RESOLVED OBSOLETE
Product: libxslt
Classification: Platform
Component: general
1.1.x
Other All
: Normal minor
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-05-27 02:12 UTC by Matt McCutchen 1
Modified: 2021-07-05 10:59 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14



Description Matt McCutchen 1 2006-05-27 02:12:55 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.
Comment 1 Matt McCutchen 1 2009-11-17 07:51:21 UTC
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.
Comment 2 GNOME Infrastructure Team 2021-07-05 10:59:56 UTC
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.