I broke magic byte detection, and missed some Content-Security-Policy opportunities.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4304 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
478e96fc5f
commit
2ca08d21e4
@ -473,7 +473,7 @@ function startsWithBytes(data, bytes) {
|
||||
if (data.byteLength >= bytes.length) {
|
||||
let dataBytes = new Uint8Array(data.slice(0, bytes.length));
|
||||
for (let i = 0; i < bytes.length; i++) {
|
||||
if (dataBytes[i] != bytes[i] && bytes[i] !== null) {
|
||||
if (dataBytes[i] !== bytes[i] && bytes[i] !== null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -561,7 +561,7 @@ function guessTypeFromName(path) {
|
||||
function guessTypeFromMagicBytes(data) {
|
||||
for (let magic of k_magic_bytes) {
|
||||
if (startsWithBytes(data, magic.bytes)) {
|
||||
return magic.content_type;
|
||||
return magic.type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -621,7 +621,9 @@ async function blobHandler(request, response, blobId, uri) {
|
||||
let data;
|
||||
let match;
|
||||
let query = form.decodeForm(request.query);
|
||||
let headers = {};
|
||||
let headers = {
|
||||
'Content-Security-Policy': 'sandbox',
|
||||
};
|
||||
if (query.filename && query.filename.match(/^[A-Za-z0-9\.-]*$/)) {
|
||||
headers['Content-Disposition'] = `attachment; filename=${query.filename}`;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user