Skip to content

Commit 8a3d034

Browse files
[MOD] XQuery: Base URI resolutions
1 parent 8a3dc78 commit 8a3d034

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

basex-core/src/main/java/org/basex/query/func/StandardFunc.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ protected final IO toIO(final int i, final QueryContext qc) throws QueryExceptio
363363
* @throws QueryException query exception
364364
*/
365365
protected final IO toIO(final byte[] uri) throws QueryException {
366-
final IO io = new QueryInput(string(uri), sc).io;
366+
final IO io = sc.resolve(string(uri));
367367
if(!io.exists()) throw WHICHRES_X.get(info, io);
368368
if(io instanceof IOFile && io.isDir()) throw RESDIR_X.get(info, io);
369369
return io;

basex-core/src/main/java/org/basex/query/func/fn/FnPut.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public Empty item(final QueryContext qc, final InputInfo ii) throws QueryExcepti
3636
final Updates updates = qc.updates();
3737
final DBNode target = updates.determineDataRef(nd, qc);
3838

39-
final String path = new QueryInput(string(uri.string()), sc).io.path();
39+
final String path = sc.resolve(string(uri.string())).path();
4040
// check if all target paths are unique
4141
if(!updates.putPaths.add(path)) throw UPURIDUP_X.get(info, path);
4242

basex-core/src/main/java/org/basex/query/func/fn/Parse.java

+8-14
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,22 @@ public abstract class Parse extends StandardFunc {
3636
final Item unparsedText(final QueryContext qc, final boolean check, final boolean encoding)
3737
throws QueryException {
3838

39-
final byte[] path = toTokenOrNull(exprs[0], qc);
40-
if(path == null) return check ? Bln.FALSE : Empty.VALUE;
39+
final byte[] token = toTokenOrNull(exprs[0], qc);
40+
if(token == null) return check ? Bln.FALSE : Empty.VALUE;
41+
final String path = string(token);
4142

4243
String enc;
4344
IO io;
4445
try {
4546
enc = encoding ? toEncodingOrNull(1, ENCODING_X, qc) : null;
4647

47-
final String p = string(path);
48-
if(p.indexOf('#') != -1) throw FRAGID_X.get(info, p);
49-
final Uri uri = Uri.uri(p);
50-
if(!uri.isValid()) throw INVURL_X.get(info, p);
51-
52-
if(uri.isAbsolute()) {
53-
io = IO.get(p);
54-
} else {
55-
if(sc.baseURI() == Uri.EMPTY) throw STBASEURI.get(info);
56-
io = sc.resolve(p);
57-
}
48+
if(contains(token, '#')) throw FRAGID_X.get(info, path);
49+
if(sc.baseURI() == Uri.EMPTY) throw STBASEURI.get(info);
50+
if(!Uri.uri(path).isValid()) throw INVURL_X.get(info, path);
51+
io = sc.resolve(path);
5852

5953
// overwrite path with global resource files
60-
String[] rp = qc.resources.text(p);
54+
String[] rp = qc.resources.text(path);
6155
if(rp == null) rp = qc.resources.text(io.path());
6256
if(rp != null && rp.length > 0) {
6357
io = IO.get(rp[0]);

0 commit comments

Comments
 (0)