<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>2711</bug_id>
          
          <creation_ts>2006-01-13 11:56:06 +0000</creation_ts>
          <short_desc>[xqueryx] #) in pragma content</short_desc>
          <delta_ts>2006-01-26 11:00:09 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XQueryX 1.0</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Carlisle">davidc</reporter>
          <assigned_to name="Jim Melton">jim.melton</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>7817</commentid>
    <comment_count>0</comment_count>
    <who name="David Carlisle">davidc</who>
    <bug_when>2006-01-13 11:56:06 +0000</bug_when>
    <thetext>The Xquery EBNF for pragma content is
[67]    	PragmaContents 	   ::=    	(Char* - (Char* &apos;#)&apos; Char*))

However the schema just types xqx:pragmacontents as xs:string, and the
stylesheet doesn&apos;t enforce any restriction on #) so

This is a schema valid XqueryX file which translates to a valid, executable
Xquery expression:

&lt;xqx:module xmlns:xqx=&quot;http://www.w3.org/2005/XQueryX&quot;&gt;
   &lt;xqx:mainModule&gt;
      &lt;xqx:queryBody&gt;
         &lt;xqx:extensionExpr&gt;
            &lt;xqx:pragma&gt;
               &lt;xqx:pragmaName&gt;a&lt;/xqx:pragmaName&gt;
               &lt;xqx:pragmaContents&gt; #){1},1+2,(#b&lt;/xqx:pragmaContents&gt;
            &lt;/xqx:pragma&gt;
            &lt;xqx:argExpr&gt;
               &lt;xqx:integerConstantExpr&gt;
                  &lt;xqx:value&gt;1&lt;/xqx:value&gt;
               &lt;/xqx:integerConstantExpr&gt;
            &lt;/xqx:argExpr&gt;
         &lt;/xqx:extensionExpr&gt;
      &lt;/xqx:queryBody&gt;
   &lt;/xqx:mainModule&gt;
&lt;/xqx:module&gt;

which has meaning specified by the result of transforming with the stylesheet
which is
(# a  #){1},1+2,(#b #){1}


which evaluates to the sequence 1 3 1 (assuming the pragma Qnames a and b are
unknown)


Of course the &quot;1+2&quot; above could be any Xquery expression and it means that an
XqueryX engine can not just use an XML parser but must be able to parse full
xquery syntax as well.

This could be fixed by adding a pattern facet to the schema or a check in the
stylesheet to give a fatal error if #) appears in xqx:pragmaContents

David</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7964</commentid>
    <comment_count>1</comment_count>
    <who name="Jim Melton">jim.melton</who>
    <bug_when>2006-01-25 04:19:25 +0000</bug_when>
    <thetext>Good observation! 

With a little help from my friends (thanks, Liam!), I&apos;ve modified the XQueryX
schema to use the following pattern that will exclude (i.e., fail validation)
XQueryX documents containing a pragmaContents that contains the literal sequence #)

The pattern is:
   &lt;xsd:pattern value=&quot;[^#]*([^\)]*[^#]\))*[^\)]*&quot;/&gt;

Since this does exactly what you requested, I assume that you will be willing to
mark this bug CLOSED.  Of course, if you believe that this pattern does not do
the job fully or correctly, please let me know. </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7969</commentid>
    <comment_count>2</comment_count>
    <who name="David Carlisle">davidc</who>
    <bug_when>2006-01-25 12:09:16 +0000</bug_when>
    <thetext>&gt; The pattern is:
&gt;    &lt;xsd:pattern value=&quot;[^#]*([^\)]*[^#]\))*[^\)]*&quot;/&gt;
&gt; 

I think that allows (any string containing) #))

#)) matches as shown (using . to denote a null string)

[^#]*([^\)]*[^#]\))*[^\)]*
  .     #     )  )   .


I think probably

       &lt;xsd:pattern value=&quot;[^#]*([^#]*#+[^\)]+)*#*&quot;/&gt;

does the job, although thinking about it gave me a headache:-)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7976</commentid>
    <comment_count>3</comment_count>
    <who name="Jim Melton">jim.melton</who>
    <bug_when>2006-01-25 18:12:33 +0000</bug_when>
    <thetext>Sigh...thanks for finding that error.  With Michael Sperberg-McQueen&apos;s help,
here&apos;s another (simpler, I think) pattern regex that doesn&apos;t have the problem
you identified:

(([^#]|#+[^\)#])*#*)

All of the test cases (about 50 or 60) I&apos;ve tried on this one seem to succeed. 
If you find an error on this, please report it and we&apos;ll keep on trying. </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7980</commentid>
    <comment_count>4</comment_count>
    <who name="David Carlisle">davidc</who>
    <bug_when>2006-01-26 11:00:09 +0000</bug_when>
    <thetext>&gt; (([^#]|#+[^\)#])*#*)

Look good to me, closing this report, David</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>