fix(xo-web): avoid using TextDecoder (#3718)
This is an experimental API and not really necessary here.
This commit is contained in:
parent
2e1ac27cf5
commit
2da576a1f8
@ -83,7 +83,7 @@ const filterDisks = disks => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
/* global FileReader, TextDecoder */
|
/* global FileReader */
|
||||||
|
|
||||||
async function readFileFragment (file, start = 0, end) {
|
async function readFileFragment (file, start = 0, end) {
|
||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
@ -92,18 +92,21 @@ async function readFileFragment (file, start = 0, end) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseTarHeader (header) {
|
function parseTarHeader (header) {
|
||||||
const textDecoder = new TextDecoder('ascii')
|
const fileName = Buffer.from(header.slice(0, 100))
|
||||||
const fileName = textDecoder.decode(header.slice(0, 100)).split('\0')[0]
|
.toString('ascii')
|
||||||
|
.split('\0')[0]
|
||||||
if (fileName.length === 0) {
|
if (fileName.length === 0) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const fileSize = parseInt(textDecoder.decode(header.slice(124, 124 + 11)), 8)
|
const fileSize = parseInt(
|
||||||
|
Buffer.from(header.slice(124, 124 + 11)).toString('ascii'),
|
||||||
|
8
|
||||||
|
)
|
||||||
return { fileName, fileSize }
|
return { fileName, fileSize }
|
||||||
}
|
}
|
||||||
|
|
||||||
async function parseOVF (fileFragment) {
|
async function parseOVF (fileFragment) {
|
||||||
const textDecoder = new TextDecoder('utf-8')
|
const xmlString = Buffer.from(await readFileFragment(fileFragment)).toString()
|
||||||
const xmlString = textDecoder.decode(await readFileFragment(fileFragment))
|
|
||||||
return new Promise((resolve, reject) =>
|
return new Promise((resolve, reject) =>
|
||||||
xml2js.parseString(
|
xml2js.parseString(
|
||||||
xmlString,
|
xmlString,
|
||||||
|
Loading…
Reference in New Issue
Block a user