This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 1243 - [F&O] fn:escape-uri needs to be invertible in the true() case; take out the % exception
Summary: [F&O] fn:escape-uri needs to be invertible in the true() case; take out the %...
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 1.0 (show other bugs)
Version: Last Call drafts
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Ashok Malhotra
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL: http://lists.w3.org/Archives/Public/p...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-12 19:43 UTC by C. M. Sperberg-McQueen
Modified: 2005-09-29 10:40 UTC (History)
1 user (show)

See Also:


Attachments

Description C. M. Sperberg-McQueen 2005-04-12 19:43:15 UTC
[posted in Bugzilla by cmsmcqW3.org on behalf of Dan Connolly;
text below is copied from his note to qt-comments.]

Regarding...

"Generally, $escape-reserved should be set to true when escaping a
string that is to form a single part of a URI, and to false when
escaping an entire URI or URI reference."
http://www.w3.org/TR/2005/WD-xpath-functions-20050404/#func-escape-uri

Indeed, those are the two relevant tasks. I might prefer
separate functions, as the tasks are quite unrelated.
In any case, the exception for the % character makes this
function unsuitable for the task of "form[ing] a single part of a URI".

As specified, fn:escape-uri("gross %each") returns "gross%20%each"
but that doesn't actually encode the string "gross %each" into
part of a URI such that the party that encoded it can decode it
again. In order to be useful, it needs to return
'gross%20%25each' . It needs to be invertible.

i.e. XQuery should follow all the other programming languages
out there, such as

- python
 http://docs.python.org/lib/module-urllib.html

>>> urllib.quote("gross %each")
'gross%20%25each'

- perl

perl -e 'use URI::Escape; print uri_escape("gross %each"), "\n"'
gross%20%25each

http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=URI::Escape

- javascript

http://www.javascripter.net/faq/escape.htm

I can't find the standard library functions for Java and C#
with a few minutes of googling, but I'll bet they work likewise.

p.s. yes, this is essentially the same comment I made back in 2003.
http://lists.w3.org/Archives/Public/uri/2003Mar/0027.html
Comment 1 Ashok Malhotra 2005-05-10 18:21:21 UTC
On the 5-10-05 telcon the joint WGs confirmed the decision taken during mtg 252
re. fn:escape-uri.  Essentially, this decision was 
1 remove the the percent-sign (%) from the list of characters not to be escaped
when the "escape-reserved" argument had the value "true".  
2 add the percent-sign to the list of characters not escaped when
"escape-reserved" argument had the value "false 

This means that the percent-sign is escaped when escape-reserved is "true" and
not  escaped when escape-reserved is "false".

Please confirm that this is what was intended and that it resolves the problem.