Skip to content

Commit f034d1e

Browse files
committed
Allow query to be executed from stored URI
1 parent 58b943f commit f034d1e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/main/xar-resources/api.xqm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ function api:restxq() {
584584
)
585585
};
586586

587+
587588
declare
588589
%rest:POST("{$body}")
589590
%rest:path("/pebble/query")
@@ -605,7 +606,7 @@ function api:query($range-header, $body) {
605606
then
606607
api:cors-allow(
607608
map {
608-
"code": $hsc:unauthorized,
609+
"code": $hsc:forbidden,
609610
"reason": "Guest is not allowed to execute arbitary queries"
610611
},
611612
()

src/main/xar-resources/modules/query.xqm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ import module namespace util = "http://exist-db.org/xquery/util";
1616
:)
1717
declare function qry:execute($query-data as map(xs:string, xs:string),
1818
$start as xs:integer?, $length as xs:integer?) as xs:string {
19-
let $query := $query-data?query
19+
20+
let $query :=
21+
if ($query-data?query-uri)
22+
then
23+
let $query-doc := util:binary-doc($query-data?query-uri)
24+
return
25+
util:base64-decode($query-doc)
26+
else
27+
$query-data?query
28+
2029
let $serialization := $query-data?defaultSerialization
2130
let $eval-ser-fn :=
2231
if (not(empty($start)) and not(empty($length)))

0 commit comments

Comments
 (0)