mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-02 21:33:52 +02:00
Clarify EBML strings are ASCII
This commit is contained in:
+1
-1
@@ -154,7 +154,7 @@ export class MatroskaInputFormat extends InputFormat {
|
|||||||
}
|
}
|
||||||
}; break;
|
}; break;
|
||||||
case EBMLId.DocType: {
|
case EBMLId.DocType: {
|
||||||
const docType = ebmlReader.readString(size);
|
const docType = ebmlReader.readAsciiString(size);
|
||||||
if (docType !== desiredDocType) {
|
if (docType !== desiredDocType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -312,8 +312,7 @@ export class EBMLWriter {
|
|||||||
this.writer.write(this.helper.subarray(0, pos));
|
this.writer.write(this.helper.subarray(0, pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assumes the string is ASCII
|
writeAsciiString(str: string) {
|
||||||
writeString(str: string) {
|
|
||||||
this.writer.write(new Uint8Array(str.split('').map(x => x.charCodeAt(0))));
|
this.writer.write(new Uint8Array(str.split('').map(x => x.charCodeAt(0))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,7 +358,7 @@ export class EBMLWriter {
|
|||||||
this.writeUnsignedInt(data.data, size);
|
this.writeUnsignedInt(data.data, size);
|
||||||
} else if (typeof data.data === 'string') {
|
} else if (typeof data.data === 'string') {
|
||||||
this.writeVarInt(data.data.length);
|
this.writeVarInt(data.data.length);
|
||||||
this.writeString(data.data);
|
this.writeAsciiString(data.data);
|
||||||
} else if (data.data instanceof Uint8Array) {
|
} else if (data.data instanceof Uint8Array) {
|
||||||
this.writeVarInt(data.data.byteLength, data.size);
|
this.writeVarInt(data.data.byteLength, data.size);
|
||||||
this.writer.write(data.data);
|
this.writer.write(data.data);
|
||||||
@@ -495,7 +494,7 @@ export class EBMLReader {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
readString(length: number) {
|
readAsciiString(length: number) {
|
||||||
const { view, offset } = this.reader.getViewAndOffset(this.pos, this.pos + length);
|
const { view, offset } = this.reader.getViewAndOffset(this.pos, this.pos + length);
|
||||||
this.pos += length;
|
this.pos += length;
|
||||||
|
|
||||||
|
|||||||
@@ -731,7 +731,7 @@ export class MatroskaDemuxer extends Demuxer {
|
|||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case EBMLId.DocType: {
|
case EBMLId.DocType: {
|
||||||
this.isWebM = reader.readString(size) === 'webm';
|
this.isWebM = reader.readAsciiString(size) === 'webm';
|
||||||
}; break;
|
}; break;
|
||||||
|
|
||||||
case EBMLId.Seek: {
|
case EBMLId.Seek: {
|
||||||
@@ -940,7 +940,7 @@ export class MatroskaDemuxer extends Demuxer {
|
|||||||
case EBMLId.CodecID: {
|
case EBMLId.CodecID: {
|
||||||
if (!this.currentTrack) break;
|
if (!this.currentTrack) break;
|
||||||
|
|
||||||
this.currentTrack.codecId = reader.readString(size);
|
this.currentTrack.codecId = reader.readAsciiString(size);
|
||||||
}; break;
|
}; break;
|
||||||
|
|
||||||
case EBMLId.CodecPrivate: {
|
case EBMLId.CodecPrivate: {
|
||||||
@@ -959,7 +959,7 @@ export class MatroskaDemuxer extends Demuxer {
|
|||||||
case EBMLId.Language: {
|
case EBMLId.Language: {
|
||||||
if (!this.currentTrack) break;
|
if (!this.currentTrack) break;
|
||||||
|
|
||||||
this.currentTrack.languageCode = reader.readString(size);
|
this.currentTrack.languageCode = reader.readAsciiString(size);
|
||||||
|
|
||||||
if (!isIso639Dash2LanguageCode(this.currentTrack.languageCode)) {
|
if (!isIso639Dash2LanguageCode(this.currentTrack.languageCode)) {
|
||||||
this.currentTrack.languageCode = UNDETERMINED_LANGUAGE;
|
this.currentTrack.languageCode = UNDETERMINED_LANGUAGE;
|
||||||
|
|||||||
Reference in New Issue
Block a user