Change default JSON prefix from "{} && " to ")]}', "

Issue: SPR-13078
This commit is contained in:
Sebastien Deleuze
2015-06-16 11:30:07 +02:00
parent a08c9f3137
commit 8187833502
6 changed files with 26 additions and 22 deletions

View File

@@ -99,16 +99,15 @@ public class MappingJackson2JsonView extends AbstractJackson2View {
}
/**
* Indicates whether the JSON output by this view should be prefixed with <tt>"{} && "</tt>.
* Indicates whether the JSON output by this view should be prefixed with <tt>")]}', "</tt>.
* Default is {@code false}.
* <p>Prefixing the JSON string in this manner is used to help prevent JSON Hijacking.
* The prefix renders the string syntactically invalid as a script so that it cannot be hijacked.
* This prefix does not affect the evaluation of JSON, but if JSON validation is performed
* on the string, the prefix would need to be ignored.
* This prefix should be stripped before parsing the string as JSON.
* @see #setJsonPrefix
*/
public void setPrefixJson(boolean prefixJson) {
this.jsonPrefix = (prefixJson ? "{} && " : null);
this.jsonPrefix = (prefixJson ? ")]}', " : null);
}
/**