зеркало из https://github.com/mozilla/gecko-dev.git
[PATCH] Bug 883296: returning empty object instead of null when
From 1a04770db0f0e86440503e73bded294b696b876c Mon Sep 17 00:00:00 2001 decoding zero length data in Octet.decodeMultiple. --- dom/mobilemessage/src/ril/WspPduHelper.jsm | 62 ++++++++++++++-------------- 1 file changed, 30 insertions(+), 32 deletions(-)
This commit is contained in:
Родитель
d4801377c8
Коммит
d105edd89e
|
@ -239,7 +239,7 @@ this.Octet = {
|
|||
throw new RangeError();
|
||||
}
|
||||
if (end == data.offset) {
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
|
||||
let result;
|
||||
|
@ -2291,40 +2291,38 @@ this.PduHelper = {
|
|||
|
||||
let octetArray = Octet.decodeMultiple(data, contentEnd);
|
||||
let content = null;
|
||||
if (octetArray) {
|
||||
let charset = headers["content-type"].params &&
|
||||
headers["content-type"].params.charset
|
||||
? headers["content-type"].params.charset.charset
|
||||
: null;
|
||||
let charset = headers["content-type"].params &&
|
||||
headers["content-type"].params.charset
|
||||
? headers["content-type"].params.charset.charset
|
||||
: null;
|
||||
|
||||
let mimeType = headers["content-type"].media;
|
||||
let mimeType = headers["content-type"].media;
|
||||
|
||||
if (mimeType) {
|
||||
if (mimeType == "application/smil") {
|
||||
// If the content is a SMIL type, convert it to a string.
|
||||
// We hope to save and expose the SMIL content in a string way.
|
||||
content = this.decodeStringContent(octetArray, charset);
|
||||
} else if (mimeType.indexOf("text/") == 0 && charset != "utf-8") {
|
||||
// If the content is a "text/plain" type, we have to make sure
|
||||
// the encoding of the blob content should always be "utf-8".
|
||||
let tmpStr = this.decodeStringContent(octetArray, charset);
|
||||
let encoder = new TextEncoder("UTF-8");
|
||||
content = new Blob([encoder.encode(tmpStr)], {type : mimeType});
|
||||
if (mimeType) {
|
||||
if (mimeType == "application/smil") {
|
||||
// If the content is a SMIL type, convert it to a string.
|
||||
// We hope to save and expose the SMIL content in a string way.
|
||||
content = this.decodeStringContent(octetArray, charset);
|
||||
} else if (mimeType.indexOf("text/") == 0 && charset != "utf-8") {
|
||||
// If the content is a "text/plain" type, we have to make sure
|
||||
// the encoding of the blob content should always be "utf-8".
|
||||
let tmpStr = this.decodeStringContent(octetArray, charset);
|
||||
let encoder = new TextEncoder("UTF-8");
|
||||
content = new Blob([encoder.encode(tmpStr)], {type : mimeType});
|
||||
|
||||
// Make up the missing encoding info.
|
||||
if (!headers["content-type"].params) {
|
||||
headers["content-type"].params = {};
|
||||
}
|
||||
if (!headers["content-type"].params.charset) {
|
||||
headers["content-type"].params.charset = {};
|
||||
}
|
||||
headers["content-type"].params.charset.charset = "utf-8";
|
||||
// Make up the missing encoding info.
|
||||
if (!headers["content-type"].params) {
|
||||
headers["content-type"].params = {};
|
||||
}
|
||||
if (!headers["content-type"].params.charset) {
|
||||
headers["content-type"].params.charset = {};
|
||||
}
|
||||
headers["content-type"].params.charset.charset = "utf-8";
|
||||
}
|
||||
}
|
||||
|
||||
if (!content) {
|
||||
content = new Blob([octetArray], {type : mimeType});
|
||||
}
|
||||
if (!content) {
|
||||
content = new Blob([octetArray], {type : mimeType});
|
||||
}
|
||||
|
||||
parts[i] = {
|
||||
|
|
Загрузка…
Ссылка в новой задаче