Change default JSON prefix from "{} && " to ")]}', "
Issue: SPR-13078
This commit is contained in:
@@ -101,17 +101,16 @@ public class GsonHttpMessageConverter extends AbstractHttpMessageConverter<Objec
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate whether the JSON output by this view should be prefixed with "{} &&".
|
||||
* Indicate whether the JSON output by this view should be prefixed with ")]}', ".
|
||||
* 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.
|
||||
* so that it cannot be hijacked.
|
||||
* 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -76,15 +76,14 @@ public class MappingJackson2HttpMessageConverter extends AbstractJackson2HttpMes
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate whether the JSON output by this view should be prefixed with "{} &&". Default is false.
|
||||
* Indicate whether the JSON output by this view should be prefixed with ")]}', ". Default is 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user