Updates for handling single and double quotes in html and sparql data getters
This commit is contained in:
parent
059094be4c
commit
e8840bdc23
1 changed files with 14 additions and 1 deletions
|
@ -160,9 +160,16 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
|
||||||
QuerySolution qs = results.nextSolution();
|
QuerySolution qs = results.nextSolution();
|
||||||
Literal saveToVarLiteral = qs.getLiteral("saveToVar");
|
Literal saveToVarLiteral = qs.getLiteral("saveToVar");
|
||||||
Literal queryLiteral = qs.getLiteral("query");
|
Literal queryLiteral = qs.getLiteral("query");
|
||||||
|
String queryString = queryLiteral.getString();
|
||||||
|
//we are saving the actual quotes in the n3 as escaped
|
||||||
|
//so for the json object we need to convert them into encoded
|
||||||
|
//quotes that will be reconverted on the client side for display
|
||||||
|
//Not converting them will either result in an incorrect json object
|
||||||
|
//or incorrect html
|
||||||
|
queryString = replaceQuotes(queryString);
|
||||||
Resource queryModelResource = qs.getResource("queryModel");
|
Resource queryModelResource = qs.getResource("queryModel");
|
||||||
jObject.element("saveToVar", saveToVarLiteral.getString());
|
jObject.element("saveToVar", saveToVarLiteral.getString());
|
||||||
jObject.element("query", queryLiteral.getString());
|
jObject.element("query",queryString);
|
||||||
if(queryModelResource != null) {
|
if(queryModelResource != null) {
|
||||||
jObject.element("queryModel", queryModelResource.getURI());
|
jObject.element("queryModel", queryModelResource.getURI());
|
||||||
} else {
|
} else {
|
||||||
|
@ -177,6 +184,12 @@ public class ProcessSparqlDataGetterN3 extends ProcessDataGetterAbstract {
|
||||||
return jObject;
|
return jObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Escape single and double quotes for html string to be returned to form
|
||||||
|
public String replaceQuotes(String inputStr) {
|
||||||
|
return inputStr.replaceAll("\'", "'").replaceAll("\"", """);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue