[xslt] Single Quote Character in Output Filename



We are encountering a problem with xsltproc on Windows when we specify an output filename which contains 1 or more single quotes. For instance, in this command line here:
    xsltproc -o "C:\temp\a'quote.xml" "C:\Temp\transform.xsl" "C:\Temp\input.xml"
 
We are seeing this response from xsltproc:
    runtime error
    xsltApplyStylesheet: saving to file:///C:/temp/a'quote.xml may not be possible
 
When we debug xsltproc, we have traced the problem down to the xmlParseURI() function being used by security.c, where an improper parsing of the filepath results in a null uri object which ultimately leads to a false being returned by xsltCheckWritePath() and hence the above error message.
 
Digging further into libxml, it appears that there could be a bug with the ISA_SUB_DELIM macro, where the comment associated with the macro specifies that a single quote should be included, but the macro itself has left the single quote off its list:
 
/*
 *    sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
 *                     / "*" / "+" / "," / ";" / "="
 */
#define ISA_SUB_DELIM(p)      \
      (((*(p) == '!')) || ((*(p) == '$')) || ((*(p) == '&')) ||  \
       ((*(p) == '(')) || ((*(p) == ')')) || ((*(p) == '*')) ||  \
       ((*(p) == '+')) || ((*(p) == ',')) || ((*(p) == ';')) ||  \
       ((*(p) == '=')))
This omission ends up tripping xmlParse3986Segment(), since it then stops parsing on the single quote and will result in an incomplete parse of the URI.
 
There is a workaround for this issue for xsltproc, where we specify a filename which is an already escaped URI:
    xsltproc -o "file:///C:/temp/a%27quote.xml" "C:\Temp\transform.xsl" "C:\Temp\input.xml"
 
However, given the nature and ultimate cause of the problem, we believe that the problem is much more fundamental and is at the core of the uri processing in libxml, and hence could have a larger ramification beyond that of just xsltproc. Addressing this issue at the source would seem to be the best way to go.
 
If there are possibly other suggestions for dealing with this issue, please let us know. Thanks.
 
Ray


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]