mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Don’t include an undefined X-CSRF-Token header
If there is not a `csrf-token` meta tag in the document, the blob record XHR was including an `X-CSRF-Token` header set to the string "undefined." Instead of setting it to undefined, it should not be included in the absence of a meta tag.
This commit is contained in:
parent
4ae8d6182f
commit
372dda2a29
3 changed files with 15 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
* It doesn’t include an `X-CSRF-Token` header if a meta tag is not found on
|
||||
the page. It previously included one with a value of `undefined`.
|
||||
|
||||
*Cameron Bothner*
|
||||
|
||||
* Fix `ArgumentError` when uploading to amazon s3
|
||||
|
||||
*Hiroki Sanpei*
|
||||
|
|
|
@ -560,7 +560,10 @@
|
|||
this.xhr.setRequestHeader("Content-Type", "application/json");
|
||||
this.xhr.setRequestHeader("Accept", "application/json");
|
||||
this.xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
||||
this.xhr.setRequestHeader("X-CSRF-Token", getMetaValue("csrf-token"));
|
||||
var csrfToken = getMetaValue("csrf-token");
|
||||
if (csrfToken != undefined) {
|
||||
this.xhr.setRequestHeader("X-CSRF-Token", csrfToken);
|
||||
}
|
||||
this.xhr.addEventListener("load", function(event) {
|
||||
return _this.requestDidLoad(event);
|
||||
});
|
||||
|
|
|
@ -17,7 +17,12 @@ export class BlobRecord {
|
|||
this.xhr.setRequestHeader("Content-Type", "application/json")
|
||||
this.xhr.setRequestHeader("Accept", "application/json")
|
||||
this.xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest")
|
||||
this.xhr.setRequestHeader("X-CSRF-Token", getMetaValue("csrf-token"))
|
||||
|
||||
const csrfToken = getMetaValue("csrf-token")
|
||||
if (csrfToken != undefined) {
|
||||
this.xhr.setRequestHeader("X-CSRF-Token", csrfToken)
|
||||
}
|
||||
|
||||
this.xhr.addEventListener("load", event => this.requestDidLoad(event))
|
||||
this.xhr.addEventListener("error", event => this.requestDidError(event))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue