mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-01 23:37:43 +03:00
Corrected 'Content-Length' header by using Buffer.byteLength (#10055)
Closes #10041 1. Why is this change neccesary? String.prototype.length returns the number of code units in the string (number of characters) while Buffer.byteLength returns the actual byte length of a string. 2. How does it address the issue? Places that use String.prototype.length to calculate Content-Length were switched to Buffer.byteLength instead.
This commit is contained in:
parent
7fafa1e152
commit
3f91a9e8a2
@ -21,7 +21,7 @@ const disposition = {
|
||||
return {
|
||||
'Content-Disposition': options.value,
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': JSON.stringify(result).length
|
||||
'Content-Length': Buffer.byteLength(JSON.stringify(result))
|
||||
};
|
||||
},
|
||||
|
||||
@ -29,7 +29,7 @@ const disposition = {
|
||||
return {
|
||||
'Content-Disposition': options.value,
|
||||
'Content-Type': 'application/yaml',
|
||||
'Content-Length': JSON.stringify(result).length
|
||||
'Content-Length': Buffer.byteLength(JSON.stringify(result))
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@ -229,7 +229,7 @@ const addHeaders = (apiMethod, req, res, result) => {
|
||||
res.set({
|
||||
'Content-Disposition': header,
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': JSON.stringify(result).length
|
||||
'Content-Length': Buffer.byteLength(JSON.stringify(result))
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -241,7 +241,7 @@ const addHeaders = (apiMethod, req, res, result) => {
|
||||
res.set({
|
||||
'Content-Disposition': header,
|
||||
'Content-Type': 'application/yaml',
|
||||
'Content-Length': JSON.stringify(result).length
|
||||
'Content-Length': Buffer.byteLength(JSON.stringify(result))
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user