mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1193625 - Fallback to ASCII if AutoConfig UTF-8 conversion fails. r=Mossop, mrbkap
This commit is contained in:
parent
d969325380
commit
2f472ac6fb
@ -16,6 +16,7 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsJSPrincipals.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "jswrapper.h"
|
||||
|
||||
extern PRLogModuleInfo *MCD;
|
||||
@ -106,7 +107,18 @@ nsresult EvaluateAdminConfigScript(const char *js_buffer, size_t length,
|
||||
|
||||
nsAutoCString script(js_buffer, length);
|
||||
JS::RootedValue v(cx);
|
||||
rv = xpc->EvalInSandboxObject(NS_ConvertUTF8toUTF16(script), filename, cx,
|
||||
|
||||
nsString convertedScript = NS_ConvertUTF8toUTF16(script);
|
||||
if (convertedScript.Length() == 0) {
|
||||
nsContentUtils::ReportToConsoleNonLocalized(
|
||||
NS_LITERAL_STRING("Your AutoConfig file is ASCII. Please convert it to UTF-8."),
|
||||
nsIScriptError::warningFlag,
|
||||
NS_LITERAL_CSTRING("autoconfig"),
|
||||
nullptr);
|
||||
/* If the length is 0, the conversion failed. Fallback to ASCII */
|
||||
convertedScript = NS_ConvertASCIItoUTF16(script);
|
||||
}
|
||||
rv = xpc->EvalInSandboxObject(convertedScript, filename, cx,
|
||||
autoconfigSb, JSVERSION_LATEST, &v);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user