mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 07:44:48 -05:00
fix: invalid blob type (#4536)
This commit is contained in:
parent
d4d0b5d90c
commit
7b675a332c
2 changed files with 20 additions and 13 deletions
|
@ -32,6 +32,14 @@ unitTest(function blobSlice(): void {
|
||||||
assertEquals(b4.size, blob.size);
|
assertEquals(b4.size, blob.size);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
unitTest(function blobInvalidType(): void {
|
||||||
|
const blob = new Blob(["foo"], {
|
||||||
|
type: "\u0521",
|
||||||
|
});
|
||||||
|
|
||||||
|
assertEquals(blob.type, "");
|
||||||
|
});
|
||||||
|
|
||||||
unitTest(function blobShouldNotThrowError(): void {
|
unitTest(function blobShouldNotThrowError(): void {
|
||||||
let hasThrown = false;
|
let hasThrown = false;
|
||||||
|
|
||||||
|
|
|
@ -139,14 +139,11 @@ export class DenoBlob implements domTypes.Blob {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { ending = "transparent", type = "" } = options ?? {};
|
const { ending = "transparent", type = "" } = options ?? {};
|
||||||
if (!containsOnlyASCII(type)) {
|
|
||||||
const errMsg = "The 'type' property must consist of ASCII characters.";
|
|
||||||
throw new SyntaxError(errMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
const bytes = processBlobParts(blobParts!, { ending, type });
|
|
||||||
// Normalize options.type.
|
// Normalize options.type.
|
||||||
let normalizedType = type;
|
let normalizedType = type;
|
||||||
|
if (!containsOnlyASCII(type)) {
|
||||||
|
normalizedType = "";
|
||||||
|
} else {
|
||||||
if (type.length) {
|
if (type.length) {
|
||||||
for (let i = 0; i < type.length; ++i) {
|
for (let i = 0; i < type.length; ++i) {
|
||||||
const char = type[i];
|
const char = type[i];
|
||||||
|
@ -157,6 +154,8 @@ export class DenoBlob implements domTypes.Blob {
|
||||||
}
|
}
|
||||||
normalizedType = type.toLowerCase();
|
normalizedType = type.toLowerCase();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
const bytes = processBlobParts(blobParts!, { ending, type });
|
||||||
// Set Blob object's properties.
|
// Set Blob object's properties.
|
||||||
this[bytesSymbol] = bytes;
|
this[bytesSymbol] = bytes;
|
||||||
this.size = bytes.byteLength;
|
this.size = bytes.byteLength;
|
||||||
|
|
Loading…
Reference in a new issue