Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Bugfix) misc XQTS reported issues #3693

Merged
merged 4 commits into from Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -209,6 +209,10 @@ private Source getSource(final String uriParam) throws XPathException {
throw new XPathException(this, ErrorCodes.FOUT1170, "Could not find source for: " + uriParam);
}

if (source.getInputStream()==null) {
dizzzz marked this conversation as resolved.
Show resolved Hide resolved
throw new XPathException(this, ErrorCodes.FOUT1170, "Unable to retrieve bytestream from " + uriParam);
}

if (source instanceof FileSource && !context.getBroker().getCurrentSubject().hasDbaRole()) {
throw new PermissionDeniedException("non-dba user not allowed to read from file system");
}
Expand Down
Expand Up @@ -178,8 +178,12 @@ private void nodeValueToJson(final NodeValue nodeValue, final Writer writer) thr
jsonGenerator.writeNull();
break;
case "number":
final double tempDouble = Double.parseDouble(tempString);
jsonGenerator.writeNumber(tempDouble);
try{
final double tempDouble = Double.parseDouble(tempString);
jsonGenerator.writeNumber(tempDouble);
} catch (NumberFormatException ex){
throw new XPathException(ErrorCodes.FOJS0006, "Cannot convert '" + tempString + "' to a number.");
}
break;
case "string":
if (elementValueIsEscaped == true) {
Expand Down
2 changes: 1 addition & 1 deletion exist-core/src/test/xquery/xquery3/xml-to-json.xql
Expand Up @@ -56,7 +56,7 @@ function xtj:xml-to-json-boolean($arg1) {

declare
%test:arg('arg1', '')
%test:assertError('NumberFormatException')
%test:assertError('FOJS0006')
%test:arg('arg1', '0')
%test:assertEquals('0.0')
%test:arg('arg1', '1')
Expand Down