ISSUE-98
URI escaping in SPARQL query in Recipe 6
- State:
- POSTPONED
- Product:
- Recipes
- Raised by:
- Diego Berrueta
- Opened on:
- 2008-03-16
- Description:
Escape sequences in URIs (such as %20 for whitespaces) must be double-escaped to build a SPARQL query in the implementation of Recipe 6, pattern 2. The issue and a potential solution were raised by Josh Tauberer (2008-01-20): [[[ (...) I ran into a problem when I created some URIs with %20's in them, because the redirect would need to double-escape the %20's when they are put into the query string. After some chin-scratching I found out that mod_rewrite could be used to do a proper redirect, and I've documented it here: http://rdfabout.com/demo/census/htaccess.txt There's more explanation in the link, but the short story is putting into the main httpd.conf: RewriteMap esc int:escape and then into .htaccess: RewriteEngine on RewriteBase "/" RewriteRule ^(rdf/.*) http://%{HTTP_HOST}/sparql? (..all one line..) query=DESCRIBE+<http://%{HTTP_HOST}/${esc:$1}> [R] ]]] Source: http://simile.mit.edu/mail/ReadMsg?listName=Linking%20Open%20Data&msgId=23498 [[[ # When we get URIs with %20s or other escaped characters in them, # a simple RedirectMatch won't do because in the query string # DESCRIBE query, the escaped characters will be unescaped at # some point during processing. So this is bad: # # RedirectMatch 303 (/rdf/.*) http://rdfabout.com/sparql?query=DESCRIBE+%3Chttp://www.rdfabout.com$1%3E # # Instead, we need to double-escape the characters: The percent # signs should ultimately be escaped so the processor gets back # the original escaping when unescaping is applied. # # To do this, we need to use mod_rewrite. However, mod_rewrite is # operating on the unescaped URI, so we need the 'escape' mapping # function, which needs to be activated in httpd.conf with: # RewriteMap esc int:escape # The rewrite rule below re-escapes the unescaped URI (getting back # the problematic URL we started with), and then mod_rewrite # escapes it again when it sends the redirect, finally achieving # the double-escape. RewriteEngine on RewriteBase "/" RewriteRule ^(rdf/.*) http://%{HTTP_HOST}/sparql?query=DESCRIBE+<http://%{HTTP_HOST}/${esc:$1}> [R] ]]] Source: http://rdfabout.com/demo/census/htaccess.txt
- Related emails:
- ISSUE-98: URI escaping in SPARQL query in Recipe 6 (from dean+cgi@w3.org on 2008-03-16)
- Re: [Recipes] Open issues in Recipes (from diego.berrueta@fundacionctic.org on 2008-10-04)
- Re: [Recipes] Open issues in Recipes (from diego.berrueta@fundacionctic.org on 2008-10-09)
- [Recipes] proposed resolution for remaing issues (from Diego.Berrueta@fundacionctic.org on 2008-11-03)
- Re: [Recipes] proposed resolution for remaing issues (from diego.berrueta@fundacionctic.org on 2008-11-19)
Related notes:
2008-11-19: Postponed as per http://lists.w3.org/Archives/Public/public-swd-wg/2008Nov/0003.html [[Maybe we should have added a link to this issue in the Recipes, but we didn't. The problem is real, although it won't be noticed by most of our readers. I haven't tested the proposed solution in detail, and I vaguely remember Ralph raising some concern about it during a telecon many months ago. Implementing the solution "by default" in all the recipes would obfuscate them. I think postponing the issue is the best solution: we acknowledge the problem, we provide the solution, and we can include a pointer in a future revision of the Recipes.]] Decided in http://www.w3.org/2008/11/18-swd-minutes.html#item03