зеркало из https://github.com/mozilla/gecko-dev.git
Bug 880648 - [MMS] Accented characters are not correctly sent/received in a MMS (part 1, content blob should be encoded by utf-8). r=vicamo a=leo+
This commit is contained in:
Родитель
0920d11333
Коммит
44281ac350
|
@ -11,7 +11,8 @@ dictionary MmsAttachment
|
||||||
{
|
{
|
||||||
DOMString? id;
|
DOMString? id;
|
||||||
DOMString? location;
|
DOMString? location;
|
||||||
nsIDOMBlob content;
|
nsIDOMBlob content; // If the content blob is a text/plain type, the encoding
|
||||||
|
// for text should always be "utf-8".
|
||||||
};
|
};
|
||||||
|
|
||||||
[scriptable, builtinclass, uuid(2e5e1c16-b7af-11e2-af04-8f4b1610a600)]
|
[scriptable, builtinclass, uuid(2e5e1c16-b7af-11e2-af04-8f4b1610a600)]
|
||||||
|
|
|
@ -2292,18 +2292,40 @@ this.PduHelper = {
|
||||||
let octetArray = Octet.decodeMultiple(data, contentEnd);
|
let octetArray = Octet.decodeMultiple(data, contentEnd);
|
||||||
let content = null;
|
let content = null;
|
||||||
if (octetArray) {
|
if (octetArray) {
|
||||||
// If the content is a SMIL type, convert it to a string.
|
let charset = headers["content-type"].params &&
|
||||||
// We hope to save and expose the SMIL content as a string way.
|
headers["content-type"].params.charset
|
||||||
if (headers["content-type"].media == "application/smil") {
|
? headers["content-type"].params.charset.charset
|
||||||
let charset = headers["content-type"].params &&
|
: null;
|
||||||
headers["content-type"].params.charset
|
|
||||||
? headers["content-type"].params.charset["charset"]
|
let mimeType = headers["content-type"].media;
|
||||||
: null;
|
|
||||||
content = this.decodeStringContent(octetArray, charset);
|
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 = {};
|
||||||
|
}
|
||||||
|
if (!headers["content-type"].params.charset.charset) {
|
||||||
|
headers["content-type"].params.charset.charset = "utf-8";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!content) {
|
if (!content) {
|
||||||
content = new Blob([octetArray],
|
content = new Blob([octetArray], {type : mimeType});
|
||||||
{type : headers["content-type"].media});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче