Bug 811911 - Use UTF-8 output for TwoByte chars in Error objects; r=jandem

This commit is contained in:
Terrence Cole 2015-06-04 08:43:11 -07:00
parent ffcec0c82a
commit ea3c382dcb

View File

@ -696,7 +696,6 @@ ErrorReport::init(JSContext* cx, HandleValue exn)
UniqueChars addonIdChars(JS_EncodeString(cx, addonId));
const char* filename = nullptr;
if (reportp && reportp->filename) {
filename = strrchr(reportp->filename, '/');
if (filename)
@ -775,9 +774,9 @@ ErrorReport::init(JSContext* cx, HandleValue exn)
}
if (JS_GetProperty(cx, exnObject, filename_str, &val)) {
JSString* tmp = ToString<CanGC>(cx, val);
RootedString tmp(cx, ToString<CanGC>(cx, val));
if (tmp)
filename.encodeLatin1(cx, tmp);
filename.encodeUtf8(cx, tmp);
else
cx->clearPendingException();
} else {
@ -820,7 +819,7 @@ ErrorReport::init(JSContext* cx, HandleValue exn)
}
if (str)
message_ = bytesStorage.encodeLatin1(cx, str);
message_ = bytesStorage.encodeUtf8(cx, str);
if (!message_)
message_ = "unknown (can't convert to string)";