Executing lib_only query invokes URI resolution process
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zorba |
Fix Released
|
Medium
|
Chris Hillery |
Bug Description
The following query:
module namespace foo = "http://
declare function foo:test() {
if (fn:true())
then 1
else $a
};
(which is in the Zorba source as bin/test/mymod.xq) actually contacts www.zorba-
Related branches
- Matthias Brantner: Approve
- Chris Hillery: Approve
-
Diff: 2885 lines (+12/-2758)14 files modifiedChangeLog (+2/-0)
bin/test/mymod.xq (+1/-1)
src/compiler/api/compiler_api.cpp (+9/-8)
test/fots_driver/FOTSZorbaManifest.xml (+0/-66)
test/fots_driver/README.TXT (+0/-49)
test/fots_driver/cli.xq (+0/-197)
test/fots_driver/environment.xq (+0/-561)
test/fots_driver/errors.xq (+0/-36)
test/fots_driver/evaluate.xq (+0/-565)
test/fots_driver/fots-driver.xq (+0/-752)
test/fots_driver/reporting.xq (+0/-250)
test/fots_driver/tools/dependencies.xq (+0/-27)
test/fots_driver/tools/process.xq (+0/-127)
test/fots_driver/util.xq (+0/-119)
Changed in zorba: | |
importance: | Undecided → Medium |
summary: |
- module declaration invokes URI resolution process + Executing lib_only query invokes URI resolution process |
Changed in zorba: | |
milestone: | none → 2.5 |
Changed in zorba: | |
milestone: | 2.5 → 2.8 |
Changed in zorba: | |
status: | New → Fix Committed |
status: | Fix Committed → Fix Released |
I have figured out that this only happens when compiling the query as a library module, as with the -l command-line option. This happens because Zorba actually creates a separate query that imports the module namespace and executes that, registering a custom URLResolver for that namespace URI that returns the original query.
The reason this ends up hitting the web is because the full URI mapping is also done. So, in this case, the URL "http:// www.zorba- xquery. com/foo" gets turned into a number of candidate URIs, one of which is "http:// www.zorba- xquery. com/foo. xq". The custom URLResolver recognizes only the original unchanged URI, so it returns nothing for this URI, letting Zorba fall through to the built-in URLResolvers including the HTTPURLResolver.
The fix is easy enough - simplify the custom URLResolver so it doesn't even check the URL it is passed. We know it will always be the URL we are expecting, even if it's been modified by URI Mapping, so we can just return the query file resource directly. Tested locally and this works.