Bug 1557793 part 2. Stop using [array] in nsIStringBundle. r=Pike

Differential Revision: https://phabricator.services.mozilla.com/D34196

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-06-11 15:51:51 +00:00
parent deea17a98e
commit 9de72a3ac6
153 changed files with 593 additions and 713 deletions

View File

@ -324,11 +324,11 @@ void AccessibleWrap::GetRoleDescription(role aRole,
if (aRole == roles::HEADING && aAttributes) {
// The heading level is an attribute, so we need that.
nsString level;
rv = aAttributes->GetStringProperty(NS_LITERAL_CSTRING("level"), level);
AutoTArray<nsString, 1> formatString;
rv = aAttributes->GetStringProperty(NS_LITERAL_CSTRING("level"),
*formatString.AppendElement());
if (NS_SUCCEEDED(rv)) {
const char16_t* formatString[] = {level.get()};
rv = bundle->FormatStringFromName("headingLevel", formatString, 1,
rv = bundle->FormatStringFromName("headingLevel", formatString,
aRoleDescription);
if (NS_SUCCEEDED(rv)) {
return;

View File

@ -113,7 +113,7 @@ var Utils = { // jshint ignore:line
let args = aDetails.args;
let count = aDetails.count;
if (args) {
str = bundle.formatStringFromName(string, args, args.length);
str = bundle.formatStringFromName(string, args);
} else {
str = bundle.GetStringFromName(string);
}

View File

@ -189,7 +189,7 @@ class NetErrorChild extends ActorChild {
// without replicating the complex logic from certverifier code.
case MOZILLA_PKIX_ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED:
let description = gPipNSSBundle.formatStringFromName(
"certErrorSymantecDistrustDescription1", [doc.location.hostname], 1);
"certErrorSymantecDistrustDescription1", [doc.location.hostname]);
let descriptionContainer = doc.getElementById("errorShortDescText2");
descriptionContainer.textContent = description;
@ -459,11 +459,11 @@ class NetErrorChild extends ActorChild {
msg2 = nss_error_id_str;
}
let msg = gPipNSSBundle.formatStringFromName("SSLConnectionErrorPrefix2",
[hostString, msg2], 2);
[hostString, msg2]);
if (nss_error_id_str && msg2 != nss_error_id_str) {
msg += gPipNSSBundle.formatStringFromName("certErrorCodePrefix3",
[nss_error_id_str], 1) + "\n";
[nss_error_id_str]) + "\n";
}
return msg;
}

View File

@ -500,7 +500,7 @@ class PluginChild extends ActorChild {
case "PluginClickToPlay":
this._handleClickToPlayEvent(plugin);
let pluginName = this._getPluginInfo(plugin).pluginName;
let messageString = gNavigatorBundle.formatStringFromName("PluginClickToActivate2", [pluginName], 1);
let messageString = gNavigatorBundle.formatStringFromName("PluginClickToActivate2", [pluginName]);
let overlayText = this.getPluginUI(plugin, "clickToPlay");
overlayText.textContent = messageString;
if (eventType == "PluginVulnerableUpdatable" ||
@ -885,7 +885,7 @@ class PluginChild extends ActorChild {
NPAPIPluginProcessCrashed({pluginName, runID, state}) {
let message =
gNavigatorBundle.formatStringFromName("crashedpluginsMessage.title",
[pluginName], 1);
[pluginName]);
let contentWindow = this.content;
let cwu = contentWindow.windowUtils;
@ -1010,7 +1010,7 @@ class PluginChild extends ActorChild {
let messageString =
gNavigatorBundle.formatStringFromName("crashedpluginsMessage.title",
[pluginName], 1);
[pluginName]);
this.mm.sendAsyncMessage("PluginContent:ShowPluginCrashedNotification",
{ messageString, pluginID });

View File

@ -192,7 +192,7 @@ appUpdater.prototype =
let day = buildID.slice(6, 8);
updateVersion += ` (${year}-${month}-${day})`;
}
button.label = this.bundle.formatStringFromName("update.downloadAndInstallButton.label", [updateVersion], 1);
button.label = this.bundle.formatStringFromName("update.downloadAndInstallButton.label", [updateVersion]);
button.accessKey = this.bundle.GetStringFromName("update.downloadAndInstallButton.accesskey");
}
this.updateDeck.selectedPanel = panel;

View File

@ -1190,7 +1190,7 @@ BrowserPageActions.addSearchEngine = {
let brandName = brandBundle.getString("brandShortName");
let title = searchBundle.GetStringFromName("error_invalid_engine_title");
let text = searchBundle.formatStringFromName("error_duplicate_engine_msg",
[brandName, uri], 2);
[brandName, uri]);
Services.prompt.QueryInterface(Ci.nsIPromptFactory);
let prompt = Services.prompt.getPrompt(gBrowser.contentWindow, Ci.nsIPrompt);
prompt.QueryInterface(Ci.nsIWritablePropertyBag2);

View File

@ -404,14 +404,14 @@ var gSync = {
// At this point we consider sync to be configured (but still can be in an error state).
if (status == UIState.STATUS_LOGIN_FAILED) {
let tooltipDescription = this.fxaStrings.formatStringFromName("reconnectDescription", [state.email], 1);
let tooltipDescription = this.fxaStrings.formatStringFromName("reconnectDescription", [state.email]);
let errorLabel = this.appMenuStatus.getAttribute("errorlabel");
this.appMenuContainer.setAttribute("fxastatus", "login-failed");
this.appMenuLabel.setAttribute("label", errorLabel);
this.appMenuStatus.setAttribute("tooltiptext", tooltipDescription);
return;
} else if (status == UIState.STATUS_NOT_VERIFIED) {
let tooltipDescription = this.fxaStrings.formatStringFromName("verifyDescription", [state.email], 1);
let tooltipDescription = this.fxaStrings.formatStringFromName("verifyDescription", [state.email]);
let unverifiedLabel = this.appMenuStatus.getAttribute("unverifiedlabel");
this.appMenuContainer.setAttribute("fxastatus", "unverified");
this.appMenuLabel.setAttribute("label", unverifiedLabel);
@ -937,13 +937,13 @@ var gSync = {
let tooltiptext;
if (status == UIState.STATUS_NOT_VERIFIED) {
// "needs verification"
tooltiptext = this.fxaStrings.formatStringFromName("verifyDescription", [state.email], 1);
tooltiptext = this.fxaStrings.formatStringFromName("verifyDescription", [state.email]);
} else if (status == UIState.STATUS_NOT_CONFIGURED) {
// "needs setup".
tooltiptext = this.syncStrings.GetStringFromName("signInToSync.description");
} else if (status == UIState.STATUS_LOGIN_FAILED) {
// "need to reconnect/re-enter your password"
tooltiptext = this.fxaStrings.formatStringFromName("reconnectDescription", [state.email], 1);
tooltiptext = this.fxaStrings.formatStringFromName("reconnectDescription", [state.email]);
} else {
// Sync appears configured - format the "last synced at" time.
tooltiptext = this.formatLastSyncDate(state.lastSync);
@ -969,7 +969,7 @@ var gSync = {
return null;
}
const relativeDateStr = this.relativeTimeFormat.formatBestUnit(date);
return this.syncStrings.formatStringFromName("lastSync2.label", [relativeDateStr], 1);
return this.syncStrings.formatStringFromName("lastSync2.label", [relativeDateStr]);
},
onClientsSynced() {

View File

@ -502,7 +502,7 @@ var gNavigatorBundle = {
return gBrowserBundle.GetStringFromName(key);
},
getFormattedString(key, array) {
return gBrowserBundle.formatStringFromName(key, array, array.length);
return gBrowserBundle.formatStringFromName(key, array);
},
};
@ -4131,7 +4131,7 @@ const BrowserSearch = {
let placeholder;
if (name) {
placeholder = gBrowserBundle.formatStringFromName("urlbar.placeholder",
[name], 1);
[name]);
} else {
placeholder = gURLBar.getAttribute("defaultPlaceholder");
}
@ -7737,7 +7737,7 @@ function ReportFalseDeceptiveSite() {
Services.prompt.alert(window,
bundle.GetStringFromName("errorReportFalseDeceptiveTitle"),
bundle.formatStringFromName("errorReportFalseDeceptiveMessage",
[message.data.blockedInfo.provider], 1));
[message.data.blockedInfo.provider]));
}
};
mm.addMessageListener("DeceptiveBlockedDetails:Result", onMessage);
@ -8488,7 +8488,7 @@ TabModalPromptBox.prototype = {
let spacer = document.createXULElement("spacer");
allowFocusRow.appendChild(spacer);
let label = gTabBrowserBundle.formatStringFromName("tabs.allowTabFocusByPromptForSite",
[hostForAllowFocusCheckbox], 1);
[hostForAllowFocusCheckbox]);
allowFocusCheckbox.setAttribute("label", label);
allowFocusRow.appendChild(allowFocusCheckbox);
newPrompt.ui.rows.append(allowFocusRow);

View File

@ -350,7 +350,7 @@ nsContextMenu.prototype = {
ContextualIdentityService.getUserContextLabel(gContextMenuContentData.userContextId);
item.setAttribute("label",
gBrowserBundle.formatStringFromName("userContextOpenLink.label",
[label], 1));
[label]));
}
var shouldShow = this.onSaveableLink || isMailtoInternal || this.onPlainTextLink;

View File

@ -4283,7 +4283,7 @@ window._gBrowser = {
}
}
if (tab.userContextId) {
label = gTabBrowserBundle.formatStringFromName("tabs.containers.tooltip", [label, ContextualIdentityService.getUserContextLabel(tab.userContextId)], 2);
label = gTabBrowserBundle.formatStringFromName("tabs.containers.tooltip", [label, ContextualIdentityService.getUserContextLabel(tab.userContextId)]);
}
}

View File

@ -105,7 +105,7 @@ add_task(async function test_ui_state_unverified() {
gSync.updateAllUI(state);
let expectedLabel = gSync.appMenuStatus.getAttribute("unverifiedlabel");
let tooltipText = gSync.fxaStrings.formatStringFromName("verifyDescription", [state.email], 1);
let tooltipText = gSync.fxaStrings.formatStringFromName("verifyDescription", [state.email]);
checkPanelUIStatusBar({
label: expectedLabel,
tooltip: tooltipText,
@ -128,7 +128,7 @@ add_task(async function test_ui_state_loginFailed() {
gSync.updateAllUI(state);
let expectedLabel = gSync.appMenuStatus.getAttribute("errorlabel");
let tooltipText = gSync.fxaStrings.formatStringFromName("reconnectDescription", [state.email], 1);
let tooltipText = gSync.fxaStrings.formatStringFromName("reconnectDescription", [state.email]);
checkPanelUIStatusBar({
label: expectedLabel,
tooltip: tooltipText,

View File

@ -176,7 +176,7 @@ function isDefaultIcon(icon) {
*/
function checkPermissionString(string, key, param, msg) {
let localizedString = param ?
gBrowserBundle.formatStringFromName(key, [param], 1) :
gBrowserBundle.formatStringFromName(key, [param]) :
gBrowserBundle.GetStringFromName(key);
// If this is a parameterized string and the parameter isn't given,

View File

@ -15,7 +15,7 @@ function init(event) {
let brandShortName = brand.GetStringFromName("brandShortName");
document.title =
gStringBundle.formatStringFromName("webrtcIndicator.windowtitle",
[brandShortName], 1);
[brandShortName]);
for (let id of ["audioVideoButton", "screenSharePopup"]) {
let popup = document.getElementById(id);

View File

@ -1259,15 +1259,15 @@ BrowserGlue.prototype = {
let message;
if (reason == "unused") {
message = resetBundle.formatStringFromName("resetUnusedProfile.message", [productName], 1);
message = resetBundle.formatStringFromName("resetUnusedProfile.message", [productName]);
} else if (reason == "uninstall") {
message = resetBundle.formatStringFromName("resetUninstalled.message", [productName], 1);
message = resetBundle.formatStringFromName("resetUninstalled.message", [productName]);
} else {
throw new Error(`Unknown reason (${reason}) given to _resetProfileNotification.`);
}
let buttons = [
{
label: resetBundle.formatStringFromName("refreshProfile.resetButton.label", [productName], 1),
label: resetBundle.formatStringFromName("refreshProfile.resetButton.label", [productName]),
accessKey: resetBundle.GetStringFromName("refreshProfile.resetButton.accesskey"),
callback() {
ResetProfile.openConfirmationDialog(win);
@ -2175,7 +2175,7 @@ BrowserGlue.prototype = {
var applicationName = gBrandBundle.GetStringFromName("brandShortName");
var placesBundle = Services.strings.createBundle("chrome://browser/locale/places/places.properties");
var title = placesBundle.GetStringFromName("lockPrompt.title");
var text = placesBundle.formatStringFromName("lockPrompt.text", [applicationName], 1);
var text = placesBundle.formatStringFromName("lockPrompt.text", [applicationName]);
var buttonText = placesBundle.GetStringFromName("lockPromptInfoButton.label");
var accessKey = placesBundle.GetStringFromName("lockPromptInfoButton.accessKey");
@ -2208,7 +2208,7 @@ BrowserGlue.prototype = {
let productName = gBrandBundle.GetStringFromName("brandShortName");
let title = bundle.GetStringFromName("syncStartNotification.title");
let body = bundle.formatStringFromName("syncStartNotification.body2",
[productName], 1);
[productName]);
let clickCallback = (subject, topic, data) => {
if (topic != "alertclickcallback")
@ -2788,7 +2788,7 @@ BrowserGlue.prototype = {
// we have separate strings to handle those cases. (See Also
// unnamedTabsArrivingNotificationNoDevice.body below)
if (deviceName) {
title = bundle.formatStringFromName("tabArrivingNotificationWithDevice.title", [deviceName], 1);
title = bundle.formatStringFromName("tabArrivingNotificationWithDevice.title", [deviceName]);
} else {
title = bundle.GetStringFromName("tabArrivingNotification.title");
}
@ -2801,7 +2801,7 @@ BrowserGlue.prototype = {
body = win.gURLBar.trimValue(body);
}
if (wasTruncated) {
body = bundle.formatStringFromName("singleTabArrivingWithTruncatedURL.body", [body], 1);
body = bundle.formatStringFromName("singleTabArrivingWithTruncatedURL.body", [body]);
}
} else {
title = bundle.GetStringFromName("multipleTabsArrivingNotification.title");
@ -2876,7 +2876,7 @@ BrowserGlue.prototype = {
let title = accountsBundle.GetStringFromName("deviceConnectedTitle");
let body = accountsBundle.formatStringFromName("deviceConnectedBody" +
(deviceName ? "" : ".noDeviceName"),
[deviceName], 1);
[deviceName]);
let clickCallback = async (subject, topic, data) => {
if (topic != "alertclickcallback")

View File

@ -1621,8 +1621,7 @@ var CustomizableUIInternal = {
}
try {
if (Array.isArray(aFormatArgs) && aFormatArgs.length) {
return gWidgetsBundle.formatStringFromName(name, aFormatArgs,
aFormatArgs.length) || def;
return gWidgetsBundle.formatStringFromName(name, aFormatArgs) || def;
}
return gWidgetsBundle.GetStringFromName(name) || def;
} catch (ex) {

View File

@ -153,15 +153,13 @@ var DownloadsCommon = {
strings[stringName] = function() {
// Convert "arguments" to a real array before calling into XPCOM.
return sb.formatStringFromName(stringName,
Array.from(arguments),
arguments.length);
Array.from(arguments));
};
} else if (stringName in kDownloadsStringsRequiringPluralForm) {
strings[stringName] = function(aCount) {
// Convert "arguments" to a real array before calling into XPCOM.
let formattedString = sb.formatStringFromName(stringName,
Array.from(arguments),
arguments.length);
Array.from(arguments));
return PluralForm.get(aCount, formattedString);
};
} else {

View File

@ -528,8 +528,7 @@ var MigrationUtils = Object.freeze({
if (aReplacements === undefined)
return getMigrationBundle().GetStringFromName(aKey);
return getMigrationBundle().formatStringFromName(
aKey, aReplacements, aReplacements.length);
return getMigrationBundle().formatStringFromName(aKey, aReplacements);
},
_getLocalePropertyForBrowser(browserId) {

View File

@ -566,7 +566,7 @@ class TestFirefoxRefresh(MarionetteTestCase):
container = Services.dirsvc.get("Home", Ci.nsIFile);
}
let bundle = Services.strings.createBundle("chrome://mozapps/locale/profile/profileSelection.properties");
let dirName = bundle.formatStringFromName("resetBackupDirectory", [Services.appinfo.name], 1);
let dirName = bundle.formatStringFromName("resetBackupDirectory", [Services.appinfo.name]);
container.append(dirName);
container.append(arguments[0]);
return container.path;

View File

@ -47,7 +47,7 @@ XPCOMUtils.defineLazyGetter(this, "formAutofillStorage", () => {
XPCOMUtils.defineLazyGetter(this, "reauthPasswordPromptMessage", () => {
const brandShortName = FormAutofillUtils.brandBundle.GetStringFromName("brandShortName");
return FormAutofillUtils.stringBundle.formatStringFromName(
`useCreditCardPasswordPrompt.${AppConstants.platform}`, [brandShortName], 1);
`useCreditCardPasswordPrompt.${AppConstants.platform}`, [brandShortName]);
});
/**

View File

@ -226,7 +226,7 @@ var PlacesUIUtils = {
},
getFormattedString: function PUIU_getFormattedString(key, params) {
return bundle.formatStringFromName(key, params, params.length);
return bundle.formatStringFromName(key, params);
},
/**

View File

@ -461,7 +461,7 @@ var pktUI = (function() {
var bundle = Services.strings.createBundle("chrome://browser/locale/pocket.properties");
for (let str of bundle.getSimpleEnumeration()) {
if (str.key in data) {
strings[str.key] = bundle.formatStringFromName(str.key, data[str.key], data[str.key].length);
strings[str.key] = bundle.formatStringFromName(str.key, data[str.key]);
} else {
strings[str.key] = str.value;
}

View File

@ -436,7 +436,7 @@ var gSyncPane = {
let sb = this._accountsStringBundle;
let title = sb.GetStringFromName("verification" + maybeNot + "SentTitle");
let email = !isError && data ? data.email : "";
let body = sb.formatStringFromName("verification" + maybeNot + "SentBody", [email], 1);
let body = sb.formatStringFromName("verification" + maybeNot + "SentBody", [email]);
new Notification(title, { body });
};

View File

@ -20,7 +20,7 @@ WebProtocolHandlerRegistrar.prototype = {
},
_getFormattedString(key, params) {
return this.stringBundle.formatStringFromName(key, params, params.length);
return this.stringBundle.formatStringFromName(key, params);
},
_getString(key) {

View File

@ -218,7 +218,7 @@ class MozSearchAutocompleteRichlistboxPopup extends MozElements.MozAutocompleteR
this.removeAttribute("src");
}
let headerText = this.bundle.formatStringFromName("searchHeader", [currentEngine.name], 1);
let headerText = this.bundle.formatStringFromName("searchHeader", [currentEngine.name]);
this.searchbarEngineName.setAttribute("value", headerText);
this.searchbarEngine.engine = currentEngine;
});

View File

@ -652,7 +652,7 @@ class SearchOneOffs {
}
button.id = this.telemetryOrigin + "-add-engine-" +
this._fixUpEngineNameForID(engine.title);
let label = this.bundle.formatStringFromName("cmd_addFoundEngine", [engine.title], 1);
let label = this.bundle.formatStringFromName("cmd_addFoundEngine", [engine.title]);
button.setAttribute("label", label);
button.setAttribute("crop", "end");
button.setAttribute("tooltiptext", engine.title + "\n" + engine.uri);
@ -1210,8 +1210,7 @@ class SearchOneOffs {
);
let text = searchBundle.formatStringFromName(
"error_duplicate_engine_msg",
[brandName, target.getAttribute("uri")],
2
[brandName, target.getAttribute("uri")]
);
Services.prompt.QueryInterface(Ci.nsIPromptFactory);
let prompt = Services.prompt.getPrompt(

View File

@ -4,7 +4,7 @@ const brandBundle = Services.strings.createBundle("chrome://branding/locale/bran
const brandName = brandBundle.GetStringFromName("brandShortName");
function getString(key, ...params) {
return searchBundle.formatStringFromName(key, params, params.length);
return searchBundle.formatStringFromName(key, params);
}
function AddSearchProvider(...args) {

View File

@ -300,7 +300,7 @@ class MozTranslationNotification extends MozElements.Notification {
let item = this._getAnonElt("neverForLanguage");
const kStrId = "translation.options.neverForLanguage";
item.setAttribute("label",
bundle.formatStringFromName(kStrId + ".label", [langName], 1));
bundle.formatStringFromName(kStrId + ".label", [langName]));
item.setAttribute("accesskey",
bundle.GetStringFromName(kStrId + ".accesskey"));
item.langCode = lang;

View File

@ -268,7 +268,7 @@ function makeUrlbarResult(tokens, info) {
let title = info.comment;
if (tokens && tokens.length > 1) {
title = bundle.formatStringFromName("bookmarkKeywordSearch",
[info.comment, tokens.slice(1).map(t => t.value).join(" ")], 2);
[info.comment, tokens.slice(1).map(t => t.value).join(" ")]);
}
return new UrlbarResult(
UrlbarUtils.RESULT_TYPE.KEYWORD,

View File

@ -575,7 +575,7 @@ class UrlbarView {
break;
case UrlbarUtils.RESULT_TYPE.SEARCH:
action = bundle.formatStringFromName("searchWithEngine",
[result.payload.engine], 1);
[result.payload.engine]);
break;
case UrlbarUtils.RESULT_TYPE.KEYWORD:
isVisitAction = result.payload.input.trim() == result.payload.keyword;
@ -788,7 +788,7 @@ class UrlbarView {
let action = item.querySelector(".urlbarView-action");
action.textContent =
bundle.formatStringFromName("searchWithEngine",
[(engine && engine.name) || result.payload.engine], 1);
[(engine && engine.name) || result.payload.engine]);
// If we just changed the engine from the original engine and it had an
// icon, then make sure the result now uses the new engine's icon or
// failing that the default icon. If we changed it back to the original

View File

@ -51,7 +51,7 @@ add_task(async function() {
let bundle = Services.strings.createBundle("chrome://global/locale/autocomplete.properties");
Assert.equal(result.displayed.action,
bundle.formatStringFromName("searchWithEngine", ["SearchEngine"], 1),
bundle.formatStringFromName("searchWithEngine", ["SearchEngine"]),
"Should have the correct action text");
gBrowser.removeCurrentTab();

View File

@ -15,7 +15,7 @@ var tabs = [];
add_task(async function setup() {
originalEngine = await Services.search.getDefault();
expectedString = gBrowserBundle.formatStringFromName("urlbar.placeholder", [originalEngine.name], 1);
expectedString = gBrowserBundle.formatStringFromName("urlbar.placeholder", [originalEngine.name]);
let rootDir = getRootDirectory(gTestPath);
extraEngine = await SearchTestUtils.promiseNewSearchEngine(rootDir + TEST_ENGINE_BASENAME);

View File

@ -34,7 +34,7 @@ if (AppConstants.platform == "macosx") {
const CONTENT = {
firstTimeUse: {
notificationId: "autofill-address",
message: formatStringFromName("saveAddressesMessage", [brandShortName], 1),
message: formatStringFromName("saveAddressesMessage", [brandShortName]),
anchor: {
id: "autofill-address-notification-icon",
URL: "chrome://formautofill/content/formfill-anchor.svg",
@ -97,7 +97,7 @@ const CONTENT = {
},
addCreditCard: {
notificationId: "autofill-credit-card",
message: formatStringFromName("saveCreditCardMessage", [brandShortName], 1),
message: formatStringFromName("saveCreditCardMessage", [brandShortName]),
descriptionLabel: GetStringFromName("saveCreditCardDescriptionLabel"),
descriptionIcon: true,
linkMessage: GetStringFromName(autofillSecurityOptionsKey),

View File

@ -25,7 +25,7 @@ ChromeUtils.defineModuleGetter(this, "FormLikeFactory",
XPCOMUtils.defineLazyGetter(this, "reauthPasswordPromptMessage", () => {
const brandShortName = FormAutofillUtils.brandBundle.GetStringFromName("brandShortName");
return FormAutofillUtils.stringBundle.formatStringFromName(
`useCreditCardPasswordPrompt.${AppConstants.platform}`, [brandShortName], 1);
`useCreditCardPasswordPrompt.${AppConstants.platform}`, [brandShortName]);
});
this.log = null;

View File

@ -358,7 +358,7 @@ class CreditCardResult extends ProfileAutoCompleteResult {
}
let brandName = FormAutofillUtils.brandBundle.GetStringFromName("brandShortName");
return [FormAutofillUtils.stringBundle.formatStringFromName("insecureFieldWarningDescription", [brandName], 1)];
return [FormAutofillUtils.stringBundle.formatStringFromName("insecureFieldWarningDescription", [brandName])];
}
if (this._isInputAutofilled) {

View File

@ -206,7 +206,7 @@
let warningTextTmplKey = hasExtraCategories ? "phishingWarningMessage" : "phishingWarningMessage2";
let categoriesText = showCategories.map(category => this._stringBundle.GetStringFromName(category.l10nId)).join(separator);
this._warningTextBox.textContent = this._stringBundle.formatStringFromName(warningTextTmplKey, [categoriesText], 1);
this._warningTextBox.textContent = this._stringBundle.formatStringFromName(warningTextTmplKey, [categoriesText]);
this.parentNode.parentNode.adjustHeight();
};

View File

@ -26,7 +26,7 @@ ChromeUtils.defineModuleGetter(this, "OSKeyStore",
XPCOMUtils.defineLazyGetter(this, "reauthPasswordPromptMessage", () => {
const brandShortName = FormAutofillUtils.brandBundle.GetStringFromName("brandShortName");
return FormAutofillUtils.stringBundle.formatStringFromName(
`editCreditCardPasswordPrompt.${AppConstants.platform}`, [brandShortName], 1);
`editCreditCardPasswordPrompt.${AppConstants.platform}`, [brandShortName]);
});
this.log = null;

View File

@ -92,7 +92,7 @@ this.FirefoxMonitor = {
},
getFormattedString(aKey, args) {
return this.strings.formatStringFromName(aKey, args, args.length);
return this.strings.formatStringFromName(aKey, args);
},
// We used to persist the list of hosts we've already warned the

View File

@ -507,7 +507,7 @@ var ContentSearch = {
let engine = Services.search.defaultEngine;
let favicon = engine.getIconURLBySize(16, 16);
let placeholder = this._stringBundle.formatStringFromName(
"searchWithEngine", [engine.name], 1);
"searchWithEngine", [engine.name]);
let obj = {
name: engine.name,
placeholder,

View File

@ -291,7 +291,7 @@ var ExtensionsUI = {
strings.cancelKey = bundle.GetStringFromName("webext.defaultSearchNo.accessKey");
strings.addonName = name;
strings.text = bundle.formatStringFromName("webext.defaultSearch.description",
["<>", currentEngine, newEngine], 3);
["<>", currentEngine, newEngine]);
this.showDefaultSearchPrompt(browser, strings, icon).then(respond);
}

View File

@ -112,7 +112,7 @@ var LiveBookmarkMigrator = {
root.appendChild(head);
let title = doc.createElement("title");
title.textContent =
gBrowserBundle.formatStringFromName("livebookmarkMigration.title", [appName], 1);
gBrowserBundle.formatStringFromName("livebookmarkMigration.title", [appName]);
head.appendChild(title);
let body = doc.createElement("body");

View File

@ -23,7 +23,7 @@ this.OpenInTabsUtils = {
},
getFormattedString(key, params) {
return bundle.formatStringFromName(key, params, params.length);
return bundle.formatStringFromName(key, params);
},
/**

View File

@ -727,7 +727,7 @@ GeolocationPermissionPrompt.prototype = {
}
return gBrowserBundle.formatStringFromName("geolocation.shareWithSite3",
["<>"], 1);
["<>"]);
},
get promptActions() {
@ -797,7 +797,7 @@ DesktopNotificationPermissionPrompt.prototype = {
get message() {
return gBrowserBundle.formatStringFromName("webNotifications.receiveFromSite2",
["<>"], 1);
["<>"]);
},
get promptActions() {
@ -887,7 +887,7 @@ PersistentStoragePermissionPrompt.prototype = {
get message() {
return gBrowserBundle.formatStringFromName("persistentStorage.allowWithSite",
["<>"], 1);
["<>"]);
},
get promptActions() {
@ -985,10 +985,10 @@ MIDIPermissionPrompt.prototype = {
}
} else if (this.isSysexPerm) {
message = gBrowserBundle.formatStringFromName("midi.shareSysexWithSite.message",
["<>"], 1);
["<>"]);
} else {
message = gBrowserBundle.formatStringFromName("midi.shareWithSite.message",
["<>"], 1);
["<>"]);
}
return message;
},
@ -1056,7 +1056,7 @@ StorageAccessPermissionPrompt.prototype = {
let document = this.browser.ownerDocument;
let label =
gBrowserBundle.formatStringFromName("storageAccess.description.label",
[this.prettifyHostPort(this.request.principal.URI), "<>"], 2);
[this.prettifyHostPort(this.request.principal.URI), "<>"]);
let parts = label.split("<>");
if (parts.length == 1) {
parts.push("");
@ -1086,7 +1086,7 @@ StorageAccessPermissionPrompt.prototype = {
},
get message() {
return gBrowserBundle.formatStringFromName("storageAccess.message", ["<>", "<>"], 2);
return gBrowserBundle.formatStringFromName("storageAccess.message", ["<>", "<>"]);
},
get promptActions() {

View File

@ -396,7 +396,7 @@ var SiteDataManager = {
Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1 +
Services.prompt.BUTTON_POS_0_DEFAULT;
let title = gStringBundle.GetStringFromName("clearSiteDataPromptTitle");
let text = gStringBundle.formatStringFromName("clearSiteDataPromptText", [brandName], 1);
let text = gStringBundle.formatStringFromName("clearSiteDataPromptText", [brandName]);
let btn0Label = gStringBundle.GetStringFromName("clearSiteDataNow");
let result = Services.prompt.confirmEx(

View File

@ -384,7 +384,7 @@ var defaultEngineObj = async function() {
let bundle = Services.strings.createBundle("chrome://global/locale/autocomplete.properties");
return {
name: engine.name,
placeholder: bundle.formatStringFromName("searchWithEngine", [engine.name], 1),
placeholder: bundle.formatStringFromName("searchWithEngine", [engine.name]),
iconData: await iconDataFromURI(uriFavicon),
};
};

View File

@ -1002,7 +1002,7 @@ function getGlobalIndicator() {
let menuitem = this.ownerDocument.createXULElement("menuitem");
let labelId = "webrtcIndicator.sharing" + type + "With.menuitem";
let label = stream.browser.contentTitle || stream.uri;
menuitem.setAttribute("label", bundle.formatStringFromName(labelId, [label], 1));
menuitem.setAttribute("label", bundle.formatStringFromName(labelId, [label]));
menuitem.setAttribute("disabled", "true");
this.appendChild(menuitem);
@ -1029,7 +1029,7 @@ function getGlobalIndicator() {
let item = this.ownerDocument.createXULElement("menuitem");
labelId = "webrtcIndicator.controlSharingOn.menuitem";
label = stream.browser.contentTitle || stream.uri;
item.setAttribute("label", bundle.formatStringFromName(labelId, [label], 1));
item.setAttribute("label", bundle.formatStringFromName(labelId, [label]));
item.stream = stream;
item.addEventListener("command", indicator._command);
this.appendChild(item);

View File

@ -984,10 +984,10 @@ nsresult nsScriptSecurityManager::CheckLoadURIFlags(
nsCOMPtr<nsIStringBundle> bundle = BundleHelper::GetOrCreate();
if (bundle) {
nsAutoString message;
NS_ConvertASCIItoUTF16 ucsTargetScheme(targetScheme);
const char16_t* formatStrings[] = {ucsTargetScheme.get()};
AutoTArray<nsString, 1> formatStrings;
CopyASCIItoUTF16(targetScheme, *formatStrings.AppendElement());
rv = bundle->FormatStringFromName("ProtocolFlagError", formatStrings,
ArrayLength(formatStrings), message);
message);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIConsoleService> console(
do_GetService("@mozilla.org/consoleservice;1"));
@ -1024,11 +1024,10 @@ nsresult nsScriptSecurityManager::ReportError(const char* aMessageTag,
// Localize the error message
nsAutoString message;
NS_ConvertASCIItoUTF16 ucsSourceSpec(sourceSpec);
NS_ConvertASCIItoUTF16 ucsTargetSpec(targetSpec);
const char16_t* formatStrings[] = {ucsSourceSpec.get(), ucsTargetSpec.get()};
rv = bundle->FormatStringFromName(aMessageTag, formatStrings,
ArrayLength(formatStrings), message);
AutoTArray<nsString, 2> formatStrings;
CopyASCIItoUTF16(sourceSpec, *formatStrings.AppendElement());
CopyASCIItoUTF16(targetSpec, *formatStrings.AppendElement());
rv = bundle->FormatStringFromName(aMessageTag, formatStrings, message);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIConsoleService> console(
@ -1289,13 +1288,13 @@ nsScriptSecurityManager::CanCreateWrapper(JSContext* cx, const nsIID& aIID,
nsresult rv;
nsAutoString errorMsg;
if (originUTF16.IsEmpty()) {
const char16_t* formatStrings[] = {classInfoUTF16.get()};
rv = bundle->FormatStringFromName("CreateWrapperDenied", formatStrings, 1,
AutoTArray<nsString, 1> formatStrings = {classInfoUTF16};
rv = bundle->FormatStringFromName("CreateWrapperDenied", formatStrings,
errorMsg);
} else {
const char16_t* formatStrings[] = {classInfoUTF16.get(), originUTF16.get()};
AutoTArray<nsString, 2> formatStrings = {classInfoUTF16, originUTF16};
rv = bundle->FormatStringFromName("CreateWrapperDeniedForOrigin",
formatStrings, 2, errorMsg);
formatStrings, errorMsg);
}
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -109,7 +109,7 @@ class AboutDebuggingApp extends Component {
Strings.GetStringFromName("pageNotFound")
),
dom.h4({ className: "error-page-details" },
Strings.formatStringFromName("doesNotExist", [selectedPanelId], 1))
Strings.formatStringFromName("doesNotExist", [selectedPanelId]))
)
);
}

View File

@ -27,7 +27,7 @@ class AddonsInstallError extends Component {
if (!this.props.error) {
return null;
}
const text = Strings.formatStringFromName("addonInstallError", [error.message], 1);
const text = Strings.formatStringFromName("addonInstallError", [error.message]);
const additionalErrors = Array.isArray(error.additionalErrors) ?
dom.div(

View File

@ -28,8 +28,7 @@ add_task(async function() {
const bundle = Services.strings.createBundle("chrome://global/locale/appstrings.properties");
let domain = TEST_URL_2.match(/^http:\/\/(.*)\/$/)[1];
let errorMsg = bundle.formatStringFromName("connectionFailure",
[domain], 1);
let errorMsg = bundle.formatStringFromName("connectionFailure", [domain]);
is(await getDisplayedNodeTextContent("#errorShortDescText", inspector), errorMsg,
"Inpector really inspects the error page");
@ -37,8 +36,7 @@ add_task(async function() {
await navigateTo(inspector, TEST_URL_3);
domain = TEST_URL_3.match(/^http:\/\/(.*)\/$/)[1];
errorMsg = bundle.formatStringFromName("dnsNotFound2",
[domain], 1);
errorMsg = bundle.formatStringFromName("dnsNotFound2", [domain]);
is(await getDisplayedNodeTextContent("#errorShortDescText", inspector), errorMsg,
"Inspector really inspects the new error page");

View File

@ -994,7 +994,7 @@ var Scratchpad = {
} catch (e) {
this.notificationBox.appendNotification(
this.strings.formatStringFromName("importFromFile.convert.failed",
[ charset ], 1),
[ charset ]),
"file-import-convert-failed",
null,
this.notificationBox.PRIORITY_WARNING_HIGH,
@ -1043,8 +1043,7 @@ var Scratchpad = {
if (!content) {
const message = this.strings.formatStringFromName(
"importFromFile.convert.failed",
[charsets.join(", ")],
1);
[charsets.join(", ")]);
this.notificationBox.appendNotification(
message,
"file-import-convert-failed",
@ -1518,7 +1517,7 @@ var Scratchpad = {
var statusBarField = document.getElementById("statusbar-line-col");
const { line, ch } = this.editor.getCursor();
statusBarField.textContent = this.strings.formatStringFromName(
"scratchpad.statusBarLineCol", [ line + 1, ch + 1], 2);
"scratchpad.statusBarLineCol", [ line + 1, ch + 1]);
},
/**
@ -1550,8 +1549,7 @@ var Scratchpad = {
"scratchpadIntro1",
[ShortcutUtils.prettifyShortcut(document.getElementById("sp-key-run"), true),
ShortcutUtils.prettifyShortcut(document.getElementById("sp-key-inspect"), true),
ShortcutUtils.prettifyShortcut(document.getElementById("sp-key-display"), true)],
3);
ShortcutUtils.prettifyShortcut(document.getElementById("sp-key-display"), true)]);
let args = window.arguments;
let state = null;
@ -1594,7 +1592,7 @@ var Scratchpad = {
this.updateStatusBar = Scratchpad.updateStatusBar.bind(this);
this.editor.on("cursorActivity", this.updateStatusBar);
const okstring = this.strings.GetStringFromName("selfxss.okstring");
const msg = this.strings.formatStringFromName("selfxss.msg", [okstring], 1);
const msg = this.strings.formatStringFromName("selfxss.msg", [okstring]);
this._onPaste = pasteHandlerGen(this.editor.container.contentDocument.body,
this.notificationBox, msg, okstring);

View File

@ -48,7 +48,7 @@ function runTests(sw) {
var statusBarField = sp.editor.container.ownerDocument.querySelector("#statusbar-line-col");
const { line, ch } = sp.editor.getCursor();
is(statusBarField.textContent, sp.strings.formatStringFromName(
"scratchpad.statusBarLineCol", [ line + 1, ch + 1], 2), "statusbar text is correct (" + statusBarField.textContent + ")");
"scratchpad.statusBarLineCol", [ line + 1, ch + 1]), "statusbar text is correct (" + statusBarField.textContent + ")");
finish();
}, error => {
ok(false, error);

View File

@ -44,7 +44,7 @@ function getString(name) {
return gStringBundle.GetStringFromName(name);
}
const rest = Array.prototype.slice.call(arguments, 1);
return gStringBundle.formatStringFromName(name, rest, rest.length);
return gStringBundle.formatStringFromName(name, rest);
} catch (ex) {
console.error(ex);
throw new Error("L10N error. '" + name + "' is missing from " +

View File

@ -211,7 +211,7 @@ var UI = {
updateTitle: function() {
const project = AppManager.selectedProject;
if (project) {
window.document.title = Strings.formatStringFromName("title_app", [project.name], 1);
window.document.title = Strings.formatStringFromName("title_app", [project.name]);
} else {
window.document.title = Strings.GetStringFromName("title_noApp");
}
@ -297,7 +297,7 @@ var UI = {
let text;
if (l10nArgs.length > 0) {
text = Strings.formatStringFromName(l10nProperty, l10nArgs, l10nArgs.length);
text = Strings.formatStringFromName(l10nProperty, l10nArgs);
} else {
text = Strings.GetStringFromName(l10nProperty);
}

View File

@ -130,7 +130,7 @@ var AppManager = exports.AppManager = {
} else {
let text;
if (l10nArgs.length > 0) {
text = Strings.formatStringFromName(l10nProperty, l10nArgs, l10nArgs.length);
text = Strings.formatStringFromName(l10nProperty, l10nArgs);
} else {
text = Strings.GetStringFromName(l10nProperty);
}

View File

@ -71,7 +71,7 @@ AppValidator.checkManifest = function(manifestURL) {
req.open("GET", manifestURL, true);
req.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE | Ci.nsIRequest.INHIBIT_CACHING;
} catch (e) {
error = strings.formatStringFromName("validator.invalidManifestURL", [manifestURL], 1);
error = strings.formatStringFromName("validator.invalidManifestURL", [manifestURL]);
return reject(error);
}
@ -80,7 +80,7 @@ AppValidator.checkManifest = function(manifestURL) {
try {
manifest = JSON.parse(req.responseText);
} catch (e) {
error = strings.formatStringFromName("validator.invalidManifestJSON", [e, manifestURL], 2);
error = strings.formatStringFromName("validator.invalidManifestJSON", [e, manifestURL]);
reject(error);
}
@ -88,14 +88,14 @@ AppValidator.checkManifest = function(manifestURL) {
};
req.onerror = function() {
error = strings.formatStringFromName("validator.noAccessManifestURL", [req.statusText, manifestURL], 2);
error = strings.formatStringFromName("validator.noAccessManifestURL", [req.statusText, manifestURL]);
reject(error);
};
try {
req.send(null);
} catch (e) {
error = strings.formatStringFromName("validator.noAccessManifestURL", [e, manifestURL], 2);
error = strings.formatStringFromName("validator.noAccessManifestURL", [e, manifestURL]);
reject(error);
}
});
@ -162,11 +162,11 @@ AppValidator.prototype._getManifest = function() {
try {
Services.io.newURI(manifestURL);
} catch (e) {
this.error(strings.formatStringFromName("validator.invalidHostedManifestURL", [manifestURL, e.message], 2));
this.error(strings.formatStringFromName("validator.invalidHostedManifestURL", [manifestURL, e.message]));
return Promise.resolve(null);
}
} else {
this.error(strings.formatStringFromName("validator.invalidProjectType", [this.type], 1));
this.error(strings.formatStringFromName("validator.invalidProjectType", [this.type]));
return Promise.resolve(null);
}
return this._fetchManifest(manifestURL);
@ -197,7 +197,7 @@ AppValidator.prototype.validateLaunchPath = function(manifest) {
return new Promise(resolve => {
// The launch_path field has to start with a `/`
if (manifest.launch_path && manifest.launch_path[0] !== "/") {
this.error(strings.formatStringFromName("validator.nonAbsoluteLaunchPath", [manifest.launch_path], 1));
this.error(strings.formatStringFromName("validator.nonAbsoluteLaunchPath", [manifest.launch_path]));
resolve();
}
const origin = this._getOriginURL();
@ -211,7 +211,7 @@ AppValidator.prototype.validateLaunchPath = function(manifest) {
try {
indexURL = Services.io.newURI(path, null, Services.io.newURI(origin)).spec;
} catch (e) {
this.error(strings.formatStringFromName("validator.accessFailedLaunchPath", [origin + path], 1));
this.error(strings.formatStringFromName("validator.accessFailedLaunchPath", [origin + path]));
return resolve();
}
@ -221,24 +221,24 @@ AppValidator.prototype.validateLaunchPath = function(manifest) {
req.open("HEAD", indexURL, true);
req.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE | Ci.nsIRequest.INHIBIT_CACHING;
} catch (e) {
this.error(strings.formatStringFromName("validator.accessFailedLaunchPath", [indexURL], 1));
this.error(strings.formatStringFromName("validator.accessFailedLaunchPath", [indexURL]));
return resolve();
}
req.onload = () => {
if (req.status >= 400) {
this.error(strings.formatStringFromName("validator.accessFailedLaunchPathBadHttpCode", [indexURL, req.status], 2));
this.error(strings.formatStringFromName("validator.accessFailedLaunchPathBadHttpCode", [indexURL, req.status]));
}
resolve();
};
req.onerror = () => {
this.error(strings.formatStringFromName("validator.accessFailedLaunchPath", [indexURL], 1));
this.error(strings.formatStringFromName("validator.accessFailedLaunchPath", [indexURL]));
resolve();
};
try {
req.send(null);
} catch (e) {
this.error(strings.formatStringFromName("validator.accessFailedLaunchPath", [indexURL], 1));
this.error(strings.formatStringFromName("validator.accessFailedLaunchPath", [indexURL]));
resolve();
}
});
@ -247,10 +247,10 @@ AppValidator.prototype.validateLaunchPath = function(manifest) {
AppValidator.prototype.validateType = function(manifest) {
const appType = manifest.type || "web";
if (!["web", "privileged", "certified"].includes(appType)) {
this.error(strings.formatStringFromName("validator.invalidAppType", [appType], 1));
this.error(strings.formatStringFromName("validator.invalidAppType", [appType]));
} else if (this.type == "hosted" &&
["certified", "privileged"].includes(appType)) {
this.error(strings.formatStringFromName("validator.invalidHostedPriviledges", [appType], 1));
this.error(strings.formatStringFromName("validator.invalidHostedPriviledges", [appType]));
}
// certified app are not fully supported on the simulator

View File

@ -140,7 +140,7 @@ RuntimeList.prototype = {
const noADBExtensionNode = doc.querySelector("#runtime-panel-noadbextension");
const noUSBNode = doc.querySelector("#runtime-panel-nousbdevice");
noADBExtensionNode.textContent =
Strings.formatStringFromName("runtimePanel_noadbextension", ["ADB Extension"], 1);
Strings.formatStringFromName("runtimePanel_noadbextension", ["ADB Extension"]);
if (adbAddon.status === ADB_ADDON_STATES.INSTALLED) {
noADBExtensionNode.setAttribute("hidden", "true");

View File

@ -92,7 +92,7 @@
const validator = createHosted("wrong-launch-path");
validator.validate().then(() => {
is(validator.errors.length, 1, "app with non-existant launch path got an error");
is(validator.errors[0], strings.formatStringFromName("validator.accessFailedLaunchPathBadHttpCode", [fakeOrigin + "wrong-path.html", 404], 2),
is(validator.errors[0], strings.formatStringFromName("validator.accessFailedLaunchPathBadHttpCode", [fakeOrigin + "wrong-path.html", 404]),
"with the right error message");
is(validator.warnings.length, 0, "but no warning");
next();
@ -105,7 +105,7 @@
const file = nsFile(validator.location);
file.append("wrong-path.html");
const url = Services.io.newFileURI(file);
is(validator.errors[0], strings.formatStringFromName("validator.accessFailedLaunchPath", [url.spec], 1),
is(validator.errors[0], strings.formatStringFromName("validator.accessFailedLaunchPath", [url.spec]),
"with the expected message");
is(validator.warnings.length, 0, "but no warning");
@ -118,7 +118,7 @@
const validator = createHosted("non-absolute-path");
validator.validate().then(() => {
is(validator.errors.length, 1, "app with non absolute path got an error");
is(validator.errors[0], strings.formatStringFromName("validator.nonAbsoluteLaunchPath", ["non-absolute.html"], 1),
is(validator.errors[0], strings.formatStringFromName("validator.nonAbsoluteLaunchPath", ["non-absolute.html"]),
"with expected message");
is(validator.warnings.length, 0, "but no warning");
next();
@ -128,7 +128,7 @@
const validator = createPackaged("non-absolute-path");
validator.validate().then(() => {
is(validator.errors.length, 1, "app with non absolute path got an error");
is(validator.errors[0], strings.formatStringFromName("validator.nonAbsoluteLaunchPath", ["non-absolute.html"], 1),
is(validator.errors[0], strings.formatStringFromName("validator.nonAbsoluteLaunchPath", ["non-absolute.html"]),
"with expected message");
is(validator.warnings.length, 0, "but no warning");
next();

View File

@ -4067,9 +4067,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
// The key used to select the appropriate error message from the properties
// file.
const char* errorDescriptionID = nullptr;
const uint32_t kMaxFormatStrArgs = 3;
nsAutoString formatStrs[kMaxFormatStrArgs];
uint32_t formatStrCount = 0;
AutoTArray<nsString, 3> formatStrs;
bool addHostPort = false;
nsresult rv = NS_OK;
nsAutoString messageStr;
@ -4085,7 +4083,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
// Extract the schemes into a comma delimited list.
nsAutoCString scheme;
aURI->GetScheme(scheme);
CopyASCIItoUTF16(scheme, formatStrs[0]);
CopyASCIItoUTF16(scheme, *formatStrs.AppendElement());
nsCOMPtr<nsINestedURI> nestedURI = do_QueryInterface(aURI);
while (nestedURI) {
nsCOMPtr<nsIURI> tempURI;
@ -4098,7 +4096,6 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
}
nestedURI = do_QueryInterface(tempURI);
}
formatStrCount = 1;
error = "unknownProtocolFound";
} else if (NS_ERROR_FILE_NOT_FOUND == aError) {
NS_ENSURE_ARG_POINTER(aURI);
@ -4112,8 +4109,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
nsAutoCString host;
nsCOMPtr<nsIURI> innermostURI = NS_GetInnermostURI(aURI);
innermostURI->GetHost(host);
CopyUTF8toUTF16(host, formatStrs[0]);
formatStrCount = 1;
CopyUTF8toUTF16(host, *formatStrs.AppendElement());
errorDescriptionID = "dnsNotFound2";
error = "dnsNotFound";
} else if (NS_ERROR_CONNECTION_REFUSED == aError ||
@ -4131,8 +4127,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
// Get the host
nsAutoCString host;
aURI->GetHost(host);
CopyUTF8toUTF16(host, formatStrs[0]);
formatStrCount = 1;
CopyUTF8toUTF16(host, *formatStrs.AppendElement());
error = "netTimeout";
} else if (NS_ERROR_CSP_FRAME_ANCESTOR_VIOLATION == aError ||
NS_ERROR_CSP_FORM_ACTION_VIOLATION == aError) {
@ -4236,8 +4231,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
NS_ERROR_HARMFUL_URI == aError) {
nsAutoCString host;
aURI->GetHost(host);
CopyUTF8toUTF16(host, formatStrs[0]);
formatStrCount = 1;
CopyUTF8toUTF16(host, *formatStrs.AppendElement());
// Malware and phishing detectors may want to use an alternate error
// page, but if the pref's not set, we'll fall back on the standard page
@ -4434,11 +4428,12 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
} else {
hostport.Assign('?');
}
CopyUTF8toUTF16(hostport, formatStrs[formatStrCount++]);
CopyUTF8toUTF16(hostport, *formatStrs.AppendElement());
}
nsAutoCString spec;
rv = NS_ERROR_NOT_AVAILABLE;
auto& nextFormatStr = *formatStrs.AppendElement();
if (aURI) {
// displaying "file://" is aesthetically unpleasing and could even be
// confusing to the user
@ -4452,26 +4447,21 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv)) {
rv = textToSubURI->UnEscapeURIForUI(NS_LITERAL_CSTRING("UTF-8"), spec,
formatStrs[formatStrCount]);
nextFormatStr);
}
} else {
spec.Assign('?');
}
if (NS_FAILED(rv)) {
CopyUTF8toUTF16(spec, formatStrs[formatStrCount]);
CopyUTF8toUTF16(spec, nextFormatStr);
}
rv = NS_OK;
++formatStrCount;
const char16_t* strs[kMaxFormatStrArgs];
for (uint32_t i = 0; i < formatStrCount; i++) {
strs[i] = formatStrs[i].get();
}
nsAutoString str;
rv = stringBundle->FormatStringFromName(errorDescriptionID, strs,
formatStrCount, str);
rv =
stringBundle->FormatStringFromName(errorDescriptionID, formatStrs, str);
NS_ENSURE_SUCCESS(rv, rv);
messageStr.Assign(str.get());
messageStr.Assign(str);
}
// Display the error as a page or an alert prompt
@ -12060,8 +12050,9 @@ nsresult nsDocShell::ConfirmRepost(bool* aRepost) {
NS_ASSERTION(prompter && brandBundle && appBundle,
"Unable to set up repost prompter.");
nsAutoString brandName;
rv = brandBundle->GetStringFromName("brandShortName", brandName);
AutoTArray<nsString, 1> formatStrings;
rv = brandBundle->GetStringFromName("brandShortName",
*formatStrings.AppendElement());
nsAutoString msgString, button0Title;
if (NS_FAILED(rv)) { // No brand, use the generic version.
@ -12070,9 +12061,8 @@ nsresult nsDocShell::ConfirmRepost(bool* aRepost) {
// Brand available - if the app has an override file with formatting, the
// app name will be included. Without an override, the prompt will look
// like the generic version.
const char16_t* formatStrings[] = {brandName.get()};
rv = appBundle->FormatStringFromName("confirmRepostPrompt", formatStrings,
ArrayLength(formatStrings), msgString);
msgString);
}
if (NS_FAILED(rv)) {
return rv;

View File

@ -114,8 +114,7 @@ class EventSourceImpl final : public nsIObserver,
static void TimerCallback(nsITimer* aTimer, void* aClosure);
nsresult PrintErrorOnConsole(const char* aBundleURI, const char* aError,
const char16_t** aFormatStrings,
uint32_t aFormatStringsLen);
const nsTArray<nsString>& aFormatStrings);
nsresult ConsoleError();
static nsresult StreamReaderFunc(nsIInputStream* aInputStream, void* aClosure,
@ -1156,10 +1155,9 @@ nsresult EventSourceImpl::SetReconnectionTimeout() {
return NS_OK;
}
nsresult EventSourceImpl::PrintErrorOnConsole(const char* aBundleURI,
const char* aError,
const char16_t** aFormatStrings,
uint32_t aFormatStringsLen) {
nsresult EventSourceImpl::PrintErrorOnConsole(
const char* aBundleURI, const char* aError,
const nsTArray<nsString>& aFormatStrings) {
AssertIsOnMainThread();
MOZ_ASSERT(!IsShutDown());
nsCOMPtr<nsIStringBundleService> bundleService =
@ -1181,9 +1179,8 @@ nsresult EventSourceImpl::PrintErrorOnConsole(const char* aBundleURI,
// Localize the error message
nsAutoString message;
if (aFormatStrings) {
rv = strBundle->FormatStringFromName(aError, aFormatStrings,
aFormatStringsLen, message);
if (!aFormatStrings.IsEmpty()) {
rv = strBundle->FormatStringFromName(aError, aFormatStrings, message);
} else {
rv = strBundle->GetStringFromName(aError, message);
}
@ -1208,17 +1205,15 @@ nsresult EventSourceImpl::ConsoleError() {
nsresult rv = mSrc->GetSpec(targetSpec);
NS_ENSURE_SUCCESS(rv, rv);
NS_ConvertUTF8toUTF16 specUTF16(targetSpec);
const char16_t* formatStrings[] = {specUTF16.get()};
AutoTArray<nsString, 1> formatStrings;
CopyUTF8toUTF16(targetSpec, *formatStrings.AppendElement());
if (ReadyState() == CONNECTING) {
rv = PrintErrorOnConsole("chrome://global/locale/appstrings.properties",
"connectionFailure", formatStrings,
ArrayLength(formatStrings));
"connectionFailure", formatStrings);
} else {
rv = PrintErrorOnConsole("chrome://global/locale/appstrings.properties",
"netInterrupt", formatStrings,
ArrayLength(formatStrings));
"netInterrupt", formatStrings);
}
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -3604,7 +3604,14 @@ nsresult nsContentUtils::FormatLocalizedString(PropertiesFile aFile,
return bundle->GetStringFromName(aKey, aResult);
}
return bundle->FormatStringFromName(aKey, aParams, aParamsLength, aResult);
// XXXbz Temporary. Will change the signature of FormatLocalizedString in the
// next changeset, but it has lots of callsites and this changeset was already
// getting big.
nsTArray<nsString> params(aParamsLength);
for (uint32_t i = 0; i < aParamsLength; ++i) {
params.AppendElement(aParams[i]);
}
return bundle->FormatStringFromName(aKey, params, aResult);
}
/* static */

View File

@ -25,7 +25,7 @@ function getExpectedStrings() {
try {
let brandName = brandBundle.GetStringFromName("brandShortName");
result.message = appBundle.formatStringFromName("confirmRepostPrompt",
[brandName], 1);
[brandName]);
} catch (e) {
// for the case that we don't have brandShortName
result.message = appBundle.GetStringFromName("confirmRepostPrompt");

View File

@ -1519,10 +1519,11 @@ nsresult HTMLFormElement::GetActionURL(nsIURI** aActionURL,
NS_ENSURE_SUCCESS(rv, rv);
if (isHttpScheme && document->GetUpgradeInsecureRequests(false)) {
// let's use the old specification before the upgrade for logging
AutoTArray<nsString, 2> params;
nsAutoCString spec;
rv = actionURL->GetSpec(spec);
NS_ENSURE_SUCCESS(rv, rv);
NS_ConvertUTF8toUTF16 reportSpec(spec);
CopyUTF8toUTF16(spec, *params.AppendElement());
// upgrade the actionURL from http:// to use https://
nsCOMPtr<nsIURI> upgradedActionURL;
@ -1534,11 +1535,10 @@ nsresult HTMLFormElement::GetActionURL(nsIURI** aActionURL,
nsAutoCString scheme;
rv = actionURL->GetScheme(scheme);
NS_ENSURE_SUCCESS(rv, rv);
NS_ConvertUTF8toUTF16 reportScheme(scheme);
CopyUTF8toUTF16(scheme, *params.AppendElement());
const char16_t* params[] = {reportSpec.get(), reportScheme.get()};
CSP_LogLocalizedStr(
"upgradeInsecureRequest", params, ArrayLength(params),
"upgradeInsecureRequest", params,
EmptyString(), // aSourceFile
EmptyString(), // aScriptSample
0, // aLineNumber

View File

@ -580,11 +580,10 @@ nsresult ImageDocument::OnLoadComplete(imgIRequest* aRequest,
if (NS_FAILED(aStatus) && mStringBundle && mImageContent) {
nsAutoCString src;
mDocumentURI->GetSpec(src);
NS_ConvertUTF8toUTF16 srcString(src);
const char16_t* formatString[] = {srcString.get()};
AutoTArray<nsString, 1> formatString;
CopyUTF8toUTF16(src, *formatString.AppendElement());
nsAutoString errorMsg;
mStringBundle->FormatStringFromName("InvalidImage", formatString, 1,
errorMsg);
mStringBundle->FormatStringFromName("InvalidImage", formatString, errorMsg);
mImageContent->SetAttr(kNameSpaceID_None, nsGkAtoms::alt, errorMsg, false);
}
@ -784,11 +783,10 @@ void ImageDocument::UpdateTitleAndCharset() {
nsAutoString status;
if (mImageIsResized) {
nsAutoString ratioStr;
ratioStr.AppendInt(NSToCoordFloor(GetRatio() * 100));
AutoTArray<nsString, 1> formatString;
formatString.AppendElement()->AppendInt(NSToCoordFloor(GetRatio() * 100));
const char16_t* formatString[1] = {ratioStr.get()};
mStringBundle->FormatStringFromName("ScaledImage", formatString, 1, status);
mStringBundle->FormatStringFromName("ScaledImage", formatString, status);
}
static const char* const formatNames[4] = {

View File

@ -347,26 +347,25 @@ void MediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr,
heightStr.AppendInt(aHeight);
// If we got a filename, display it
if (!fileStr.IsEmpty()) {
const char16_t* formatStrings[4] = {fileStr.get(), typeStr.get(),
widthStr.get(), heightStr.get()};
AutoTArray<nsString, 4> formatStrings = {fileStr, typeStr, widthStr,
heightStr};
mStringBundle->FormatStringFromName(aFormatNames[eWithDimAndFile],
formatStrings, 4, title);
formatStrings, title);
} else {
const char16_t* formatStrings[3] = {typeStr.get(), widthStr.get(),
heightStr.get()};
AutoTArray<nsString, 3> formatStrings = {typeStr, widthStr, heightStr};
mStringBundle->FormatStringFromName(aFormatNames[eWithDim],
formatStrings, 3, title);
formatStrings, title);
}
} else {
// If we got a filename, display it
if (!fileStr.IsEmpty()) {
const char16_t* formatStrings[2] = {fileStr.get(), typeStr.get()};
AutoTArray<nsString, 2> formatStrings = {fileStr, typeStr};
mStringBundle->FormatStringFromName(aFormatNames[eWithFile],
formatStrings, 2, title);
formatStrings, title);
} else {
const char16_t* formatStrings[1] = {typeStr.get()};
AutoTArray<nsString, 1> formatStrings = {typeStr};
mStringBundle->FormatStringFromName(aFormatNames[eWithNoInfo],
formatStrings, 1, title);
formatStrings, title);
}
}
}
@ -377,12 +376,12 @@ void MediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr,
SetTitle(title, ignored);
} else {
nsAutoString titleWithStatus;
const nsPromiseFlatString& status = PromiseFlatString(aStatus);
const char16_t* formatStrings[2] = {title.get(), status.get()};
mStringBundle->FormatStringFromName("TitleWithStatus", formatStrings, 2,
AutoTArray<nsString, 2> formatStrings;
formatStrings.AppendElement(title);
formatStrings.AppendElement(aStatus);
mStringBundle->FormatStringFromName("TitleWithStatus", formatStrings,
titleWithStatus);
IgnoredErrorResult ignored;
SetTitle(titleWithStatus, ignored);
SetTitle(titleWithStatus, IgnoreErrors());
}
}

View File

@ -34,8 +34,7 @@ ValueExtractor.prototype = {
if (type !== expectedType) {
if (type !== "undefined") {
this.console.warn(this.domBundle.formatStringFromName("ManifestInvalidType",
[objectName, property, expectedType],
3));
[objectName, property, expectedType]));
}
return undefined;
}
@ -56,8 +55,7 @@ ValueExtractor.prototype = {
rgba.b).toString(16);
} else if (value) {
this.console.warn(this.domBundle.formatStringFromName("ManifestInvalidCSSColor",
[spec.property, value],
2));
[spec.property, value]));
}
return color;
},
@ -69,8 +67,7 @@ ValueExtractor.prototype = {
langTag = Intl.getCanonicalLocales(value)[0];
} catch (err) {
console.warn(this.domBundle.formatStringFromName("ManifestLangIsInvalid",
[spec.property, value],
2));
[spec.property, value]));
}
}
return langTag;

View File

@ -72,8 +72,7 @@ class CryptoError extends Error {
*/
format(scope) {
let params = [scope, ...this.params].map(String);
return gDOMBundle.formatStringFromName(this.property, params,
params.length);
return gDOMBundle.formatStringFromName(this.property, params);
}
}

View File

@ -178,9 +178,9 @@ static bool ShouldIgnoreFrameOptions(nsIChannel* aChannel,
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
uint64_t innerWindowID = loadInfo->GetInnerWindowID();
bool privateWindow = !!loadInfo->GetOriginAttributes().mPrivateBrowsingId;
const char16_t* params[] = {u"x-frame-options", u"frame-ancestors"};
AutoTArray<nsString, 2> params = {NS_LITERAL_STRING("x-frame-options"),
NS_LITERAL_STRING("frame-ancestors")};
CSP_LogLocalizedStr("IgnoringSrcBecauseOfDirective", params,
ArrayLength(params),
EmptyString(), // no sourcefile
EmptyString(), // no scriptsample
0, // no linenumber

View File

@ -804,8 +804,8 @@ void nsCSPContext::flushConsoleMessages() {
mConsoleMsgQueue.Clear();
}
void nsCSPContext::logToConsole(const char* aName, const char16_t** aParams,
uint32_t aParamsLength,
void nsCSPContext::logToConsole(const char* aName,
const nsTArray<nsString>& aParams,
const nsAString& aSourceName,
const nsAString& aSourceLine,
uint32_t aLineNumber, uint32_t aColumnNumber,
@ -817,7 +817,7 @@ void nsCSPContext::logToConsole(const char* aName, const char16_t** aParams,
// let's check if we have to queue up console messages
if (mQueueUpMessages) {
nsAutoString msg;
CSP_GetLocalizedStr(aName, aParams, aParamsLength, msg);
CSP_GetLocalizedStr(aName, aParams, msg);
ConsoleMsgQueueElem& elem = *mConsoleMsgQueue.AppendElement();
elem.mMsg = msg;
elem.mSourceName = PromiseFlatString(aSourceName);
@ -836,9 +836,9 @@ void nsCSPContext::logToConsole(const char* aName, const char16_t** aParams,
!!doc->NodePrincipal()->OriginAttributesRef().mPrivateBrowsingId;
}
CSP_LogLocalizedStr(aName, aParams, aParamsLength, aSourceName, aSourceLine,
aLineNumber, aColumnNumber, aSeverityFlag, category,
mInnerWindowID, privateWindow);
CSP_LogLocalizedStr(aName, aParams, aSourceName, aSourceLine, aLineNumber,
aColumnNumber, aSeverityFlag, category, mInnerWindowID,
privateWindow);
}
/**
@ -1054,12 +1054,11 @@ nsresult nsCSPContext::SendReports(
// try to create a new uri from every report-uri string
rv = NS_NewURI(getter_AddRefs(reportURI), reportURIs[r]);
if (NS_FAILED(rv)) {
const char16_t* params[] = {reportURIs[r].get()};
AutoTArray<nsString, 1> params = {reportURIs[r]};
CSPCONTEXTLOG(("Could not create nsIURI for report URI %s",
reportURICstring.get()));
logToConsole("triedToSendReport", params, ArrayLength(params),
aViolationEventInit.mSourceFile, aViolationEventInit.mSample,
aViolationEventInit.mLineNumber,
logToConsole("triedToSendReport", params, aViolationEventInit.mSourceFile,
aViolationEventInit.mSample, aViolationEventInit.mLineNumber,
aViolationEventInit.mColumnNumber,
nsIScriptError::errorFlag);
continue; // don't return yet, there may be more URIs
@ -1091,12 +1090,11 @@ nsresult nsCSPContext::SendReports(
isHttpScheme);
if (!isHttpScheme) {
const char16_t* params[] = {reportURIs[r].get()};
logToConsole("reportURInotHttpsOrHttp2", params, ArrayLength(params),
aViolationEventInit.mSourceFile, aViolationEventInit.mSample,
aViolationEventInit.mLineNumber,
aViolationEventInit.mColumnNumber,
nsIScriptError::errorFlag);
AutoTArray<nsString, 1> params = {reportURIs[r]};
logToConsole(
"reportURInotHttpsOrHttp2", params, aViolationEventInit.mSourceFile,
aViolationEventInit.mSample, aViolationEventInit.mLineNumber,
aViolationEventInit.mColumnNumber, nsIScriptError::errorFlag);
continue;
}
@ -1164,12 +1162,11 @@ nsresult nsCSPContext::SendReports(
// reports don't go out, but it's good to log the error locally.
if (NS_FAILED(rv)) {
const char16_t* params[] = {reportURIs[r].get()};
AutoTArray<nsString, 1> params = {reportURIs[r]};
CSPCONTEXTLOG(("AsyncOpen failed for report URI %s",
NS_ConvertUTF16toUTF8(params[0]).get()));
logToConsole("triedToSendReport", params, ArrayLength(params),
aViolationEventInit.mSourceFile, aViolationEventInit.mSample,
aViolationEventInit.mLineNumber,
logToConsole("triedToSendReport", params, aViolationEventInit.mSourceFile,
aViolationEventInit.mSample, aViolationEventInit.mLineNumber,
aViolationEventInit.mColumnNumber,
nsIScriptError::errorFlag);
} else {
@ -1325,12 +1322,12 @@ class CSPReportSenderRunnable final : public Runnable {
if (blockedContentSource.Length() > 0) {
nsString blockedContentSource16 =
NS_ConvertUTF8toUTF16(blockedContentSource);
const char16_t* params[] = {mViolatedDirective.get(),
blockedContentSource16.get()};
AutoTArray<nsString, 2> params = {mViolatedDirective,
blockedContentSource16};
mCSPContext->logToConsole(
mReportOnlyFlag ? "CSPROViolationWithURI" : "CSPViolationWithURI",
params, ArrayLength(params), mSourceFile, mScriptSample, mLineNum,
mColumnNum, nsIScriptError::errorFlag);
params, mSourceFile, mScriptSample, mLineNum, mColumnNum,
nsIScriptError::errorFlag);
}
// 4) fire violation event
@ -1604,10 +1601,9 @@ nsCSPContext::GetCSPSandboxFlags(uint32_t* aOutSandboxFlags) {
"sandbox in: %s",
NS_ConvertUTF16toUTF8(policy).get()));
const char16_t* params[] = {policy.get()};
logToConsole("ignoringReportOnlyDirective", params, ArrayLength(params),
EmptyString(), EmptyString(), 0, 0,
nsIScriptError::warningFlag);
AutoTArray<nsString, 1> params = {policy};
logToConsole("ignoringReportOnlyDirective", params, EmptyString(),
EmptyString(), 0, 0, nsIScriptError::warningFlag);
}
}

View File

@ -70,10 +70,10 @@ class nsCSPContext : public nsIContentSecurityPolicy {
*/
void flushConsoleMessages();
void logToConsole(const char* aName, const char16_t** aParams,
uint32_t aParamsLength, const nsAString& aSourceName,
const nsAString& aSourceLine, uint32_t aLineNumber,
uint32_t aColumnNumber, uint32_t aSeverityFlag);
void logToConsole(const char* aName, const nsTArray<nsString>& aParams,
const nsAString& aSourceName, const nsAString& aSourceLine,
uint32_t aLineNumber, uint32_t aColumnNumber,
uint32_t aSeverityFlag);
/**
* Construct SecurityPolicyViolationEventInit structure.

View File

@ -180,12 +180,11 @@ bool nsCSPParser::atValidPathChar() {
void nsCSPParser::logWarningErrorToConsole(uint32_t aSeverityFlag,
const char* aProperty,
const char16_t* aParams[],
uint32_t aParamsLength) {
const nsTArray<nsString>& aParams) {
CSPPARSERLOG(("nsCSPParser::logWarningErrorToConsole: %s", aProperty));
// send console messages off to the context and let the context
// deal with it (potentially messages need to be queued up)
mCSPContext->logToConsole(aProperty, aParams, aParamsLength,
mCSPContext->logToConsole(aProperty, aParams,
EmptyString(), // aSourceName
EmptyString(), // aSourceLine
0, // aLineNumber
@ -230,9 +229,9 @@ bool nsCSPParser::port() {
// Port must start with a number
if (!accept(isNumberToken)) {
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag, "couldntParsePort",
params, ArrayLength(params));
params);
return false;
}
// Consume more numbers and set parsed port to the nsCSPHost
@ -265,10 +264,9 @@ bool nsCSPParser::subPath(nsCSPHostSrc* aCspHost) {
// first part is "/path1", second part "/path2"
resetCurValue();
} else if (!atValidPathChar()) {
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"couldntParseInvalidSource", params,
ArrayLength(params));
"couldntParseInvalidSource", params);
return false;
}
// potentially we have encountred a valid pct-encoded character in
@ -304,10 +302,9 @@ bool nsCSPParser::path(nsCSPHostSrc* aCspHost) {
resetCurValue();
if (!accept(SLASH)) {
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"couldntParseInvalidSource", params,
ArrayLength(params));
"couldntParseInvalidSource", params);
return false;
}
if (atEndOfPath()) {
@ -321,10 +318,9 @@ bool nsCSPParser::path(nsCSPHostSrc* aCspHost) {
// path can begin with "/" but not "//"
// see http://tools.ietf.org/html/rfc3986#section-3.3
if (peek(SLASH)) {
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"couldntParseInvalidSource", params,
ArrayLength(params));
"couldntParseInvalidSource", params);
return false;
}
return subPath(aCspHost);
@ -373,29 +369,26 @@ nsCSPHostSrc* nsCSPParser::host() {
}
// If the token is not only the "*", a "." must follow right after
if (!accept(DOT)) {
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"couldntParseInvalidHost", params,
ArrayLength(params));
"couldntParseInvalidHost", params);
return nullptr;
}
}
// Expecting at least one host-char
if (!hostChar()) {
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"couldntParseInvalidHost", params,
ArrayLength(params));
"couldntParseInvalidHost", params);
return nullptr;
}
// There might be several sub hosts defined.
if (!subHost()) {
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"couldntParseInvalidHost", params,
ArrayLength(params));
"couldntParseInvalidHost", params);
return nullptr;
}
@ -403,10 +396,9 @@ nsCSPHostSrc* nsCSPParser::host() {
if (CSP_IsQuotelessKeyword(mCurValue)) {
nsString keyword = mCurValue;
ToLowerCase(keyword);
const char16_t* params[] = {mCurToken.get(), keyword.get()};
AutoTArray<nsString, 2> params = {mCurToken, keyword};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"hostNameMightBeKeyword", params,
ArrayLength(params));
"hostNameMightBeKeyword", params);
}
// Create a new nsCSPHostSrc with the parsed host.
@ -437,10 +429,9 @@ nsCSPBaseSrc* nsCSPParser::keywordSource() {
if (!CSP_IsDirective(mCurDir[0],
nsIContentSecurityPolicy::SCRIPT_SRC_DIRECTIVE)) {
// Todo: Enforce 'strict-dynamic' within default-src; see Bug 1313937
const char16_t* params[] = {u"strict-dynamic"};
AutoTArray<nsString, 1> params = {NS_LITERAL_STRING("strict-dynamic")};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"ignoringStrictDynamic", params,
ArrayLength(params));
"ignoringStrictDynamic", params);
return nullptr;
}
mStrictDynamic = true;
@ -456,10 +447,9 @@ nsCSPBaseSrc* nsCSPParser::keywordSource() {
// make sure script-src only contains 'unsafe-inline' once;
// ignore duplicates and log warning
if (mUnsafeInlineKeywordSrc) {
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"ignoringDuplicateSrc", params,
ArrayLength(params));
"ignoringDuplicateSrc", params);
return nullptr;
}
// cache if we encounter 'unsafe-inline' so we can invalidate (ignore) it in
@ -671,10 +661,9 @@ nsCSPBaseSrc* nsCSPParser::sourceExpression() {
// If mCurToken provides not only a scheme, but also a host, we have to
// check if two slashes follow the scheme.
if (!accept(SLASH) || !accept(SLASH)) {
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"failedToParseUnrecognizedSource", params,
ArrayLength(params));
"failedToParseUnrecognizedSource", params);
return nullptr;
}
}
@ -747,10 +736,10 @@ void nsCSPParser::sourceList(nsTArray<nsCSPBaseSrc*>& outSrcs) {
}
// Otherwise, we ignore 'none' and report a warning
else {
const char16_t* params[] = {CSP_EnumToUTF16Keyword(CSP_NONE)};
AutoTArray<nsString, 1> params;
params.AppendElement(CSP_EnumToUTF16Keyword(CSP_NONE));
logWarningErrorToConsole(nsIScriptError::warningFlag,
"ignoringUnknownOption", params,
ArrayLength(params));
"ignoringUnknownOption", params);
}
}
}
@ -774,10 +763,9 @@ void nsCSPParser::reportURIList(nsCSPDirective* aDir) {
// If creating the URI casued an error, skip this URI
if (NS_FAILED(rv)) {
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"couldNotParseReportURI", params,
ArrayLength(params));
"couldNotParseReportURI", params);
continue;
}
@ -787,10 +775,9 @@ void nsCSPParser::reportURIList(nsCSPDirective* aDir) {
}
if (srcs.Length() == 0) {
const char16_t* directiveName[] = {mCurToken.get()};
AutoTArray<nsString, 1> directiveName = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"ignoringDirectiveWithNoValues", directiveName,
ArrayLength(directiveName));
"ignoringDirectiveWithNoValues", directiveName);
delete aDir;
return;
}
@ -817,10 +804,9 @@ void nsCSPParser::sandboxFlagList(nsCSPDirective* aDir) {
NS_ConvertUTF16toUTF8(mCurValue).get()));
if (!nsContentUtils::IsValidSandboxFlag(mCurToken)) {
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"couldntParseInvalidSandboxFlag", params,
ArrayLength(params));
"couldntParseInvalidSandboxFlag", params);
continue;
}
@ -854,10 +840,9 @@ nsCSPDirective* nsCSPParser::directiveName() {
// Check if it is a valid directive
if (!CSP_IsValidDirective(mCurToken)) {
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"couldNotProcessUnknownDirective", params,
ArrayLength(params));
"couldNotProcessUnknownDirective", params);
return nullptr;
}
@ -867,19 +852,18 @@ nsCSPDirective* nsCSPParser::directiveName() {
// warning to the console and ignore the directive including its values.
if (CSP_IsDirective(mCurToken,
nsIContentSecurityPolicy::REFLECTED_XSS_DIRECTIVE)) {
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"notSupportingDirective", params,
ArrayLength(params));
"notSupportingDirective", params);
return nullptr;
}
// Make sure the directive does not already exist
// (see http://www.w3.org/TR/CSP11/#parsing)
if (mPolicy->hasDirective(CSP_StringToCSPDirective(mCurToken))) {
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag, "duplicateDirective",
params, ArrayLength(params));
params);
return nullptr;
}
@ -894,10 +878,9 @@ nsCSPDirective* nsCSPParser::directiveName() {
(CSP_IsDirective(mCurToken,
nsIContentSecurityPolicy::SANDBOX_DIRECTIVE)))) {
// log to the console to indicate that meta CSP is ignoring the directive
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"ignoringSrcFromMetaCSP", params,
ArrayLength(params));
"ignoringSrcFromMetaCSP", params);
return nullptr;
}
@ -919,10 +902,9 @@ nsCSPDirective* nsCSPParser::directiveName() {
// * for frames (if frame-src is not explicitly specified)
if (CSP_IsDirective(mCurToken,
nsIContentSecurityPolicy::CHILD_SRC_DIRECTIVE)) {
const char16_t* params[] = {mCurToken.get()};
AutoTArray<nsString, 1> params = {mCurToken};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"deprecatedChildSrcDirective", params,
ArrayLength(params));
"deprecatedChildSrcDirective", params);
mChildSrc = new nsCSPChildSrcDirective(CSP_StringToCSPDirective(mCurToken));
return mChildSrc;
}
@ -966,10 +948,9 @@ void nsCSPParser::directive() {
// Make sure that the directive-srcs-array contains at least
// one directive and one src.
if (mCurDir.Length() < 1) {
const char16_t* params[] = {u"directive missing"};
AutoTArray<nsString, 1> params = {NS_LITERAL_STRING("directive missing")};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"failedToParseUnrecognizedSource", params,
ArrayLength(params));
"failedToParseUnrecognizedSource", params);
return;
}
@ -989,10 +970,10 @@ void nsCSPParser::directive() {
// by a directive name but does not include any srcs.
if (cspDir->equals(nsIContentSecurityPolicy::BLOCK_ALL_MIXED_CONTENT)) {
if (mCurDir.Length() > 1) {
const char16_t* params[] = {u"block-all-mixed-content"};
AutoTArray<nsString, 1> params = {
NS_LITERAL_STRING("block-all-mixed-content")};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"ignoreSrcForDirective", params,
ArrayLength(params));
"ignoreSrcForDirective", params);
}
// add the directive and return
mPolicy->addDirective(cspDir);
@ -1003,10 +984,10 @@ void nsCSPParser::directive() {
// specified by a directive name but does not include any srcs.
if (cspDir->equals(nsIContentSecurityPolicy::UPGRADE_IF_INSECURE_DIRECTIVE)) {
if (mCurDir.Length() > 1) {
const char16_t* params[] = {u"upgrade-insecure-requests"};
AutoTArray<nsString, 1> params = {
NS_LITERAL_STRING("upgrade-insecure-requests")};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"ignoreSrcForDirective", params,
ArrayLength(params));
"ignoreSrcForDirective", params);
}
// add the directive and return
mPolicy->addUpgradeInsecDir(
@ -1072,29 +1053,26 @@ void nsCSPParser::directive() {
!StringBeginsWith(
srcStr, nsDependentString(CSP_EnumToUTF16Keyword(CSP_NONCE))) &&
!StringBeginsWith(srcStr, NS_LITERAL_STRING("'sha"))) {
const char16_t* params[] = {srcStr.get()};
AutoTArray<nsString, 1> params = {srcStr};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"ignoringSrcForStrictDynamic", params,
ArrayLength(params));
"ignoringSrcForStrictDynamic", params);
}
}
// Log a warning that all scripts might be blocked because the policy
// contains 'strict-dynamic' but no valid nonce or hash.
if (!mHasHashOrNonce) {
const char16_t* params[] = {mCurDir[0].get()};
AutoTArray<nsString, 1> params = {mCurDir[0]};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"strictDynamicButNoHashOrNonce", params,
ArrayLength(params));
"strictDynamicButNoHashOrNonce", params);
}
} else if (mHasHashOrNonce && mUnsafeInlineKeywordSrc &&
(cspDir->equals(nsIContentSecurityPolicy::SCRIPT_SRC_DIRECTIVE) ||
cspDir->equals(nsIContentSecurityPolicy::STYLE_SRC_DIRECTIVE))) {
mUnsafeInlineKeywordSrc->invalidate();
// log to the console that unsafe-inline will be ignored
const char16_t* params[] = {u"'unsafe-inline'"};
AutoTArray<nsString, 1> params = {NS_LITERAL_STRING("'unsafe-inline'")};
logWarningErrorToConsole(nsIScriptError::warningFlag,
"ignoringSrcWithinScriptStyleSrc", params,
ArrayLength(params));
"ignoringSrcWithinScriptStyleSrc", params);
}
// Add the newly created srcs to the directive and add the directive to the
@ -1176,11 +1154,10 @@ nsCSPPolicy* nsCSPParser::parseContentSecurityPolicy(
nsAutoCString prePath;
nsresult rv = aSelfURI->GetPrePath(prePath);
NS_ENSURE_SUCCESS(rv, policy);
NS_ConvertUTF8toUTF16 unicodePrePath(prePath);
const char16_t* params[] = {unicodePrePath.get()};
AutoTArray<nsString, 1> params;
CopyUTF8toUTF16(prePath, *params.AppendElement());
parser.logWarningErrorToConsole(nsIScriptError::warningFlag,
"reportURInotInReportOnlyHeader", params,
ArrayLength(params));
"reportURInotInReportOnlyHeader", params);
}
}

View File

@ -108,8 +108,7 @@ class nsCSPParser {
void resetCurChar(const nsAString& aToken);
void logWarningErrorToConsole(uint32_t aSeverityFlag, const char* aProperty,
const char16_t* aParams[],
uint32_t aParamsLength);
const nsTArray<nsString>& aParams);
/**
* When parsing the policy, the parser internally uses the following helper

View File

@ -117,8 +117,8 @@ bool CSP_ShouldResponseInheritCSP(nsIChannel* aChannel) {
return isBlob || isData || isFS || isJS;
}
void CSP_GetLocalizedStr(const char* aName, const char16_t** aParams,
uint32_t aLength, nsAString& outResult) {
void CSP_GetLocalizedStr(const char* aName, const nsTArray<nsString>& aParams,
nsAString& outResult) {
nsCOMPtr<nsIStringBundle> keyStringBundle;
nsCOMPtr<nsIStringBundleService> stringBundleService =
mozilla::services::GetStringBundleService();
@ -133,7 +133,7 @@ void CSP_GetLocalizedStr(const char* aName, const char16_t** aParams,
if (!keyStringBundle) {
return;
}
keyStringBundle->FormatStringFromName(aName, aParams, aLength, outResult);
keyStringBundle->FormatStringFromName(aName, aParams, outResult);
}
void CSP_LogStrMessage(const nsAString& aMsg) {
@ -204,14 +204,14 @@ void CSP_LogMessage(const nsAString& aMessage, const nsAString& aSourceName,
/**
* Combines CSP_LogMessage and CSP_GetLocalizedStr into one call.
*/
void CSP_LogLocalizedStr(const char* aName, const char16_t** aParams,
uint32_t aLength, const nsAString& aSourceName,
void CSP_LogLocalizedStr(const char* aName, const nsTArray<nsString>& aParams,
const nsAString& aSourceName,
const nsAString& aSourceLine, uint32_t aLineNumber,
uint32_t aColumnNumber, uint32_t aFlags,
const nsACString& aCategory, uint64_t aInnerWindowID,
bool aFromPrivateWindow) {
nsAutoString logMsg;
CSP_GetLocalizedStr(aName, aParams, aLength, logMsg);
CSP_GetLocalizedStr(aName, aParams, logMsg);
CSP_LogMessage(logMsg, aSourceName, aSourceLine, aLineNumber, aColumnNumber,
aFlags, aCategory, aInnerWindowID, aFromPrivateWindow);
}

View File

@ -27,15 +27,15 @@ struct CSP;
/* =============== Logging =================== */
void CSP_LogLocalizedStr(const char* aName, const char16_t** aParams,
uint32_t aLength, const nsAString& aSourceName,
void CSP_LogLocalizedStr(const char* aName, const nsTArray<nsString>& aParams,
const nsAString& aSourceName,
const nsAString& aSourceLine, uint32_t aLineNumber,
uint32_t aColumnNumber, uint32_t aFlags,
const nsACString& aCategory, uint64_t aInnerWindowID,
bool aFromPrivateWindow);
void CSP_GetLocalizedStr(const char* aName, const char16_t** aParams,
uint32_t aLength, nsAString& outResult);
void CSP_GetLocalizedStr(const char* aName, const nsTArray<nsString>& aParams,
nsAString& outResult);
void CSP_LogStrMessage(const nsAString& aMsg);

View File

@ -821,11 +821,12 @@ nsresult nsMixedContentBlocker::ShouldLoad(
nsAutoCString spec;
rv = aContentLocation->GetSpec(spec);
NS_ENSURE_SUCCESS(rv, rv);
NS_ConvertUTF8toUTF16 reportSpec(spec);
const char16_t* params[] = {reportSpec.get()};
AutoTArray<nsString, 1> params;
CopyUTF8toUTF16(spec, *params.AppendElement());
CSP_LogLocalizedStr(
"blockAllMixedContent", params, ArrayLength(params),
"blockAllMixedContent", params,
EmptyString(), // aSourceFile
EmptyString(), // aScriptSample
0, // aLineNumber

View File

@ -20,7 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=847081
var stringBundleService = SpecialPowers.Cc["@mozilla.org/intl/stringbundle;1"]
.getService(SpecialPowers.Ci.nsIStringBundleService);
var localizer = stringBundleService.createBundle("chrome://global/locale/security/csp.properties");
var warningMsg = localizer.formatStringFromName("reportURInotInReportOnlyHeader", [window.location.origin], 1);
var warningMsg = localizer.formatStringFromName("reportURInotInReportOnlyHeader", [window.location.origin]);
function cleanup() {
SpecialPowers.postConsoleSentinel();
SimpleTest.finish();

View File

@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=587377
var stringBundleService = SpecialPowers.Cc["@mozilla.org/intl/stringbundle;1"]
.getService(SpecialPowers.Ci.nsIStringBundleService);
var localizer = stringBundleService.createBundle("chrome://global/locale/security/csp.properties");
var confusionMsg = localizer.formatStringFromName("hostNameMightBeKeyword", ["SELF", "self"], 2);
var confusionMsg = localizer.formatStringFromName("hostNameMightBeKeyword", ["SELF", "self"]);
function cleanup() {
SpecialPowers.postConsoleSentinel();

View File

@ -41,7 +41,7 @@ function expect_console_message(/* msgId, args, ... */) {
expectations.push({errorMessage: localizer.GetStringFromName(msgId)});
} else {
expectations.push({
errorMessage: localizer.formatStringFromName(msgId, args, args.length)
errorMessage: localizer.formatStringFromName(msgId, args)
});
}
}

View File

@ -59,7 +59,7 @@ function waitForMessages() {
for (let i = 0; i < arguments.length; i += 3) {
let msgId = arguments[i];
let args = arguments[i + 1];
messages.push(security_localizer.formatStringFromName(msgId, args, args.length));
messages.push(security_localizer.formatStringFromName(msgId, args));
}
return new Promise(resolve => {
@ -89,7 +89,7 @@ function expect_security_console_message(/* msgId, args, ... */) {
let args = arguments[i + 1];
let filename = arguments[i + 2];
expectations.push({
errorMessage: security_localizer.formatStringFromName(msgId, args, args.length),
errorMessage: security_localizer.formatStringFromName(msgId, args),
sourceName: filename,
});
}

View File

@ -1091,15 +1091,15 @@ nsresult nsWebBrowserPersist::SendErrorStatusChange(bool aIsReadError,
// Get the file path or spec from the supplied URI
nsCOMPtr<nsIFile> file;
GetLocalFileFromURI(aURI, getter_AddRefs(file));
nsAutoString path;
AutoTArray<nsString, 1> strings;
nsresult rv;
if (file) {
file->GetPath(path);
file->GetPath(*strings.AppendElement());
} else {
nsAutoCString fileurl;
rv = aURI->GetSpec(fileurl);
NS_ENSURE_SUCCESS(rv, rv);
AppendUTF8toUTF16(fileurl, path);
CopyUTF8toUTF16(fileurl, *strings.AppendElement());
}
const char* msgId;
@ -1146,9 +1146,7 @@ nsresult nsWebBrowserPersist::SendErrorStatusChange(bool aIsReadError,
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && bundle, NS_ERROR_FAILURE);
nsAutoString msgText;
const char16_t* strings[1];
strings[0] = path.get();
rv = bundle->FormatStringFromName(msgId, strings, 1, msgText);
rv = bundle->FormatStringFromName(msgId, strings, msgText);
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
mProgressListener->OnStatusChange(nullptr, aRequest, aResult, msgText.get());

View File

@ -142,8 +142,7 @@ class WebSocketImpl final : public nsIInterfaceRequestor,
nsresult ConsoleError();
void PrintErrorOnConsole(const char* aBundleURI, const char* aError,
const char16_t** aFormatStrings,
uint32_t aFormatStringsLen);
nsTArray<nsString>&& aFormatStrings);
nsresult DoOnMessageAvailable(const nsACString& aMsg, bool isBinary);
@ -264,20 +263,17 @@ class PrintErrorOnConsoleRunnable final : public WorkerMainThreadRunnable {
public:
PrintErrorOnConsoleRunnable(WebSocketImpl* aImpl, const char* aBundleURI,
const char* aError,
const char16_t** aFormatStrings,
uint32_t aFormatStringsLen)
nsTArray<nsString>&& aFormatStrings)
: WorkerMainThreadRunnable(
aImpl->mWorkerRef->Private(),
NS_LITERAL_CSTRING("WebSocket :: print error on console")),
mImpl(aImpl),
mBundleURI(aBundleURI),
mError(aError),
mFormatStrings(aFormatStrings),
mFormatStringsLen(aFormatStringsLen) {}
mFormatStrings(std::move(aFormatStrings)) {}
bool MainThreadRun() override {
mImpl->PrintErrorOnConsole(mBundleURI, mError, mFormatStrings,
mFormatStringsLen);
mImpl->PrintErrorOnConsole(mBundleURI, mError, std::move(mFormatStrings));
return true;
}
@ -287,16 +283,14 @@ class PrintErrorOnConsoleRunnable final : public WorkerMainThreadRunnable {
const char* mBundleURI;
const char* mError;
const char16_t** mFormatStrings;
uint32_t mFormatStringsLen;
nsTArray<nsString> mFormatStrings;
};
} // namespace
void WebSocketImpl::PrintErrorOnConsole(const char* aBundleURI,
const char* aError,
const char16_t** aFormatStrings,
uint32_t aFormatStringsLen) {
nsTArray<nsString>&& aFormatStrings) {
// This method must run on the main thread.
if (!NS_IsMainThread()) {
@ -304,7 +298,7 @@ void WebSocketImpl::PrintErrorOnConsole(const char* aBundleURI,
RefPtr<PrintErrorOnConsoleRunnable> runnable =
new PrintErrorOnConsoleRunnable(this, aBundleURI, aError,
aFormatStrings, aFormatStringsLen);
std::move(aFormatStrings));
ErrorResult rv;
runnable->Dispatch(Killing, rv);
// XXXbz this seems totally broken. We should be propagating this out, but
@ -334,9 +328,8 @@ void WebSocketImpl::PrintErrorOnConsole(const char* aBundleURI,
// Localize the error message
nsAutoString message;
if (aFormatStrings) {
rv = strBundle->FormatStringFromName(aError, aFormatStrings,
aFormatStringsLen, message);
if (!aFormatStrings.IsEmpty()) {
rv = strBundle->FormatStringFromName(aError, aFormatStrings, message);
} else {
rv = strBundle->GetStringFromName(aError, message);
}
@ -496,17 +489,15 @@ nsresult WebSocketImpl::ConsoleError() {
}
}
NS_ConvertUTF8toUTF16 specUTF16(mURI);
const char16_t* formatStrings[] = {specUTF16.get()};
nsTArray<nsString> formatStrings;
CopyUTF8toUTF16(mURI, *formatStrings.AppendElement());
if (mWebSocket->ReadyState() < WebSocket::OPEN) {
PrintErrorOnConsole("chrome://global/locale/appstrings.properties",
"connectionFailure", formatStrings,
ArrayLength(formatStrings));
"connectionFailure", std::move(formatStrings));
} else {
PrintErrorOnConsole("chrome://global/locale/appstrings.properties",
"netInterrupt", formatStrings,
ArrayLength(formatStrings));
"netInterrupt", std::move(formatStrings));
}
/// todo some specific errors - like for message too large
return NS_OK;
@ -1590,7 +1581,8 @@ nsresult WebSocketImpl::Init(JSContext* aCx, nsIPrincipal* aLoadingPrincipal,
if (!mIsServerSide && !mSecure && originDoc &&
originDoc->GetUpgradeInsecureRequests(false)) {
// let's use the old specification before the upgrade for logging
NS_ConvertUTF8toUTF16 reportSpec(mURI);
AutoTArray<nsString, 2> params;
CopyUTF8toUTF16(mURI, *params.AppendElement());
// upgrade the request from ws:// to wss:// and mark as secure
mURI.ReplaceSubstring("ws://", "wss://");
@ -1599,8 +1591,8 @@ nsresult WebSocketImpl::Init(JSContext* aCx, nsIPrincipal* aLoadingPrincipal,
}
mSecure = true;
const char16_t* params[] = {reportSpec.get(), u"wss"};
CSP_LogLocalizedStr("upgradeInsecureRequest", params, ArrayLength(params),
params.AppendElement(NS_LITERAL_STRING("wss"));
CSP_LogLocalizedStr("upgradeInsecureRequest", params,
EmptyString(), // aSourceFile
EmptyString(), // aScriptSample
0, // aLineNumber

View File

@ -938,7 +938,7 @@ void txMozillaXSLTProcessor::reportError(nsresult aResult,
nsCOMPtr<nsIStringBundleService> sbs =
mozilla::services::GetStringBundleService();
if (sbs) {
nsAutoString errorText;
nsString errorText;
sbs->FormatStatusMessage(aResult, EmptyString().get(), errorText);
nsAutoString errorMessage;
@ -946,12 +946,11 @@ void txMozillaXSLTProcessor::reportError(nsresult aResult,
sbs->CreateBundle(XSLT_MSGS_URL, getter_AddRefs(bundle));
if (bundle) {
const char16_t* error[] = {errorText.get()};
AutoTArray<nsString, 1> error = {errorText};
if (mStylesheet) {
bundle->FormatStringFromName("TransformError", error, 1,
errorMessage);
bundle->FormatStringFromName("TransformError", error, errorMessage);
} else {
bundle->FormatStringFromName("LoadingError", error, 1, errorMessage);
bundle->FormatStringFromName("LoadingError", error, errorMessage);
}
}
mErrorText.Assign(errorMessage);

View File

@ -183,7 +183,7 @@ function displayError(funcname, message) {
.createBundle("chrome://autoconfig/locale/autoconfig.properties");
var title = bundle.GetStringFromName("autoConfigTitle");
var msg = bundle.formatStringFromName("autoConfigMsg", [funcname], 1);
var msg = bundle.formatStringFromName("autoConfigMsg", [funcname]);
promptService.alert(null, title, msg + " " + message);
} catch (e) { }
}

View File

@ -48,23 +48,17 @@ interface nsIStringBundle : nsISupports
// the id or name should refer to a string in the bundle that
// uses %S.. do NOT try to use any other types.
// this uses nsTextFormatter::ssprintf to do the dirty work.
AString formatStringFromID(in long aID,
[array, size_is(length)] in wstring params,
in unsigned long length);
AString formatStringFromID(in long aID, in Array<AString> params);
// This method is mostly used from JS, where AUTF8String is appropriate.
[binaryname(FormatStringFromAUTF8Name)]
AString formatStringFromName(in AUTF8String aName,
[array, size_is(length)] in wstring params,
in unsigned long length);
AString formatStringFromName(in AUTF8String aName, in Array<AString> params);
// This method is mostly used from C++, where |string| is appropriate because
// the names are most often 8-bit string literals (normally ASCII, though
// u8"foo" literals will also work).
[noscript, binaryname(FormatStringFromName)]
AString formatStringFromNameCpp(in string aName,
[array, size_is(length)] in wstring params,
in unsigned long length);
AString formatStringFromNameCpp(in string aName, in Array<AString> params);
/*
Implements nsISimpleEnumerator, replaces nsIEnumerator

View File

@ -572,29 +572,29 @@ nsresult SharedStringBundle::GetStringImpl(const nsACString& aName,
}
NS_IMETHODIMP
nsStringBundleBase::FormatStringFromID(int32_t aID, const char16_t** aParams,
uint32_t aLength, nsAString& aResult) {
nsStringBundleBase::FormatStringFromID(int32_t aID,
const nsTArray<nsString>& aParams,
nsAString& aResult) {
nsAutoCString idStr;
idStr.AppendInt(aID, 10);
return FormatStringFromName(idStr.get(), aParams, aLength, aResult);
return FormatStringFromName(idStr.get(), aParams, aResult);
}
// this function supports at most 10 parameters.. see below for why
NS_IMETHODIMP
nsStringBundleBase::FormatStringFromAUTF8Name(const nsACString& aName,
const char16_t** aParams,
uint32_t aLength,
const nsTArray<nsString>& aParams,
nsAString& aResult) {
return FormatStringFromName(PromiseFlatCString(aName).get(), aParams, aLength,
return FormatStringFromName(PromiseFlatCString(aName).get(), aParams,
aResult);
}
// this function supports at most 10 parameters.. see below for why
NS_IMETHODIMP
nsStringBundleBase::FormatStringFromName(const char* aName,
const char16_t** aParams,
uint32_t aLength, nsAString& aResult) {
NS_ASSERTION(aParams && aLength,
const nsTArray<nsString>& aParams,
nsAString& aResult) {
NS_ASSERTION(!aParams.IsEmpty(),
"FormatStringFromName() without format parameters: use "
"GetStringFromName() instead");
@ -602,7 +602,7 @@ nsStringBundleBase::FormatStringFromName(const char* aName,
nsresult rv = GetStringFromName(aName, formatStr);
if (NS_FAILED(rv)) return rv;
return FormatString(formatStr.get(), aParams, aLength, aResult);
return FormatString(formatStr.get(), aParams, aResult);
}
NS_IMETHODIMP
@ -650,10 +650,10 @@ StringMapEnumerator::GetNext(nsISupports** aNext) {
}
nsresult nsStringBundleBase::FormatString(const char16_t* aFormatStr,
const char16_t** aParams,
uint32_t aLength,
const nsTArray<nsString>& aParams,
nsAString& aResult) {
NS_ENSURE_ARG(aLength <= 10); // enforce 10-parameter limit
auto length = aParams.Length();
NS_ENSURE_ARG(length <= 10); // enforce 10-parameter limit
// implementation note: you would think you could use vsmprintf
// to build up an arbitrary length array.. except that there
@ -661,13 +661,17 @@ nsresult nsStringBundleBase::FormatString(const char16_t* aFormatStr,
// Don't believe me? See:
// http://www.eskimo.com/~scs/C-faq/q15.13.html
// -alecf
nsTextFormatter::ssprintf(
aResult, aFormatStr, aLength >= 1 ? aParams[0] : nullptr,
aLength >= 2 ? aParams[1] : nullptr, aLength >= 3 ? aParams[2] : nullptr,
aLength >= 4 ? aParams[3] : nullptr, aLength >= 5 ? aParams[4] : nullptr,
aLength >= 6 ? aParams[5] : nullptr, aLength >= 7 ? aParams[6] : nullptr,
aLength >= 8 ? aParams[7] : nullptr, aLength >= 9 ? aParams[8] : nullptr,
aLength >= 10 ? aParams[9] : nullptr);
nsTextFormatter::ssprintf(aResult, aFormatStr,
length >= 1 ? aParams[0].get() : nullptr,
length >= 2 ? aParams[1].get() : nullptr,
length >= 3 ? aParams[2].get() : nullptr,
length >= 4 ? aParams[3].get() : nullptr,
length >= 5 ? aParams[4].get() : nullptr,
length >= 6 ? aParams[5].get() : nullptr,
length >= 7 ? aParams[6].get() : nullptr,
length >= 8 ? aParams[7].get() : nullptr,
length >= 9 ? aParams[8].get() : nullptr,
length >= 10 ? aParams[9].get() : nullptr);
return NS_OK;
}
@ -900,27 +904,23 @@ nsStringBundleService::CreateBundle(const char* aURLSpec,
#define GLOBAL_PROPERTIES "chrome://global/locale/global-strres.properties"
nsresult nsStringBundleService::FormatWithBundle(nsIStringBundle* bundle,
nsresult aStatus,
uint32_t argCount,
char16_t** argArray,
nsAString& result) {
nsresult nsStringBundleService::FormatWithBundle(
nsIStringBundle* bundle, nsresult aStatus,
const nsTArray<nsString>& argArray, nsAString& result) {
nsresult rv;
// try looking up the error message with the int key:
uint16_t code = NS_ERROR_GET_CODE(aStatus);
rv = bundle->FormatStringFromID(code, (const char16_t**)argArray, argCount,
result);
rv = bundle->FormatStringFromID(code, argArray, result);
// If the int key fails, try looking up the default error message. E.g. print:
// An unknown error has occurred (0x804B0003).
if (NS_FAILED(rv)) {
nsAutoString statusStr;
statusStr.AppendInt(static_cast<uint32_t>(aStatus), 16);
const char16_t* otherArgArray[1];
otherArgArray[0] = statusStr.get();
AutoTArray<nsString, 1> otherArgArray;
otherArgArray.AppendElement()->AppendInt(static_cast<uint32_t>(aStatus),
16);
uint16_t code = NS_ERROR_GET_CODE(NS_ERROR_FAILURE);
rv = bundle->FormatStringFromID(code, otherArgArray, 1, result);
rv = bundle->FormatStringFromID(code, otherArgArray, result);
}
return rv;
@ -949,23 +949,17 @@ nsStringBundleService::FormatStatusMessage(nsresult aStatus,
const nsDependentString args(aStatusArg);
argCount = args.CountChar(char16_t('\n')) + 1;
NS_ENSURE_ARG(argCount <= 10); // enforce 10-parameter limit
char16_t* argArray[10];
AutoTArray<nsString, 10> argArray;
// convert the aStatusArg into a char16_t array
// convert the aStatusArg into an nsString array
if (argCount == 1) {
// avoid construction for the simple case:
argArray[0] = (char16_t*)aStatusArg;
argArray.AppendElement(aStatusArg);
} else if (argCount > 1) {
int32_t offset = 0;
for (i = 0; i < argCount; i++) {
int32_t pos = args.FindChar('\n', offset);
if (pos == -1) pos = args.Length();
argArray[i] = ToNewUnicode(Substring(args, offset, pos - offset));
if (argArray[i] == nullptr) {
rv = NS_ERROR_OUT_OF_MEMORY;
argCount = i - 1; // don't try to free uninitialized memory
goto done;
}
argArray.AppendElement(Substring(args, offset, pos - offset));
offset = pos + 1;
}
}
@ -975,18 +969,12 @@ nsStringBundleService::FormatStatusMessage(nsresult aStatus,
getter_Copies(stringBundleURL));
if (NS_SUCCEEDED(rv)) {
getStringBundle(stringBundleURL.get(), getter_AddRefs(bundle));
rv = FormatWithBundle(bundle, aStatus, argCount, argArray, result);
rv = FormatWithBundle(bundle, aStatus, argArray, result);
}
if (NS_FAILED(rv)) {
getStringBundle(GLOBAL_PROPERTIES, getter_AddRefs(bundle));
rv = FormatWithBundle(bundle, aStatus, argCount, argArray, result);
rv = FormatWithBundle(bundle, aStatus, argArray, result);
}
done:
if (argCount > 1) {
for (i = 0; i < argCount; i++) {
if (argArray[i]) free(argArray[i]);
}
}
return rv;
}

View File

@ -62,7 +62,7 @@ class nsStringBundleBase : public nsIStringBundle, public nsIMemoryReporter {
public:
static nsresult FormatString(const char16_t* formatStr,
const char16_t** aParams, uint32_t aLength,
const nsTArray<nsString>& aParams,
nsAString& aResult);
};

View File

@ -61,7 +61,7 @@ class nsStringBundleService : public nsIStringBundleService,
void getStringBundle(const char* aUrl, nsIStringBundle** aResult);
nsresult FormatWithBundle(nsIStringBundle* bundle, nsresult aStatus,
uint32_t argCount, char16_t** argArray,
const nsTArray<nsString>& argArray,
nsAString& result);
void flushBundleCache(bool ignoreShared = true);

View File

@ -58,7 +58,7 @@ function run_test() {
var bundle_message = bundle.GetStringFromName(name_message);
Assert.equal(bundle_message, value_message);
var bundle_hello = bundle.formatStringFromName(name_hello, [var_hello], 1);
var bundle_hello = bundle.formatStringFromName(name_hello, [var_hello]);
Assert.equal(bundle_hello, value_hello);
}

View File

@ -78,7 +78,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=553917
if (name != "MMultiscriptsErrors") {
var formatParams = g_errorInfo[name].args[idx];
if (formatParams.length > 0) {
return g_bundl.formatStringFromName(name,formatParams,formatParams.length);
return g_bundl.formatStringFromName(name,formatParams);
} else {
return g_bundl.GetStringFromName(name);
}

View File

@ -35,8 +35,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=553917
function getErrorMessage(name,idx)
{
if (name != "MMultiscriptsErrors") {
return g_bundl.formatStringFromName(name,g_errorInfo[name].args[idx],
g_errorInfo[name].args[idx].length);
return g_bundl.formatStringFromName(name,g_errorInfo[name].args[idx]);
}
else {
return g_bundl.GetStringFromName(g_errorInfo[name].args[idx]);

View File

@ -302,15 +302,12 @@ void ErrorReporter::ReportUnexpected(const char* aMessage) {
AddToError(str);
}
void ErrorReporter::ReportUnexpectedUnescaped(const char* aMessage,
const nsAutoString& aParam) {
void ErrorReporter::ReportUnexpectedUnescaped(
const char* aMessage, const nsTArray<nsString>& aParam) {
MOZ_ASSERT(ShouldReportErrors(mSheet, mLoader));
const char16_t* params[1] = {aParam.get()};
nsAutoString str;
sStringBundle->FormatStringFromName(aMessage, params, ArrayLength(params),
str);
sStringBundle->FormatStringFromName(aMessage, aParam, str);
AddToError(str);
}

View File

@ -55,7 +55,7 @@ class MOZ_STACK_CLASS ErrorReporter final {
void ReportUnexpected(const char* aMessage);
// one parameter which has already been escaped appropriately
void ReportUnexpectedUnescaped(const char* aMessage,
const nsAutoString& aParam);
const nsTArray<nsString>& aParam);
private:
void OutputError();

View File

@ -1961,7 +1961,8 @@ void Gecko_ReportUnexpectedCSSError(
if (prefix) {
if (prefixParam) {
nsDependentCSubstring paramValue(prefixParam, prefixParamLen);
nsAutoString wideParam = NS_ConvertUTF8toUTF16(paramValue);
AutoTArray<nsString, 1> wideParam;
CopyUTF8toUTF16(paramValue, *wideParam.AppendElement());
reporter.ReportUnexpectedUnescaped(prefix, wideParam);
} else {
reporter.ReportUnexpected(prefix);
@ -1970,7 +1971,8 @@ void Gecko_ReportUnexpectedCSSError(
if (param) {
nsDependentCSubstring paramValue(param, paramLen);
nsAutoString wideParam = NS_ConvertUTF8toUTF16(paramValue);
AutoTArray<nsString, 1> wideParam;
CopyUTF8toUTF16(paramValue, *wideParam.AppendElement());
reporter.ReportUnexpectedUnescaped(message, wideParam);
} else {
reporter.ReportUnexpected(message);

View File

@ -22,7 +22,7 @@ var ConsoleAPI = {
let functionName = args[0].functionName || bundle.GetStringFromName("stacktrace.anonymousFunction");
let lineNumber = args[0].lineNumber;
let body = bundle.formatStringFromName("stacktrace.outputMessage", [filename, functionName, lineNumber], 3);
let body = bundle.formatStringFromName("stacktrace.outputMessage", [filename, functionName, lineNumber]);
body += "\n";
args.forEach(function(aFrame) {
let functionName = aFrame.functionName || bundle.GetStringFromName("stacktrace.anonymousFunction");
@ -32,11 +32,11 @@ var ConsoleAPI = {
Services.console.logStringMessage(body);
} else if (aMessage.level == "time" && aMessage.arguments) {
let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
let body = bundle.formatStringFromName("timer.start", [aMessage.arguments.name], 1);
let body = bundle.formatStringFromName("timer.start", [aMessage.arguments.name]);
Services.console.logStringMessage(body);
} else if (aMessage.level == "timeEnd" && aMessage.arguments) {
let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
let body = bundle.formatStringFromName("timer.end", [aMessage.arguments.name, aMessage.arguments.duration], 2);
let body = bundle.formatStringFromName("timer.end", [aMessage.arguments.name, aMessage.arguments.duration]);
Services.console.logStringMessage(body);
} else if (["group", "groupCollapsed", "groupEnd"].includes(aMessage.level)) {
// Do nothing yet

View File

@ -45,7 +45,7 @@ var OfflineApps = {
}];
let requestor = BrowserApp.manifest ? "'" + BrowserApp.manifest.name + "'" : host;
let message = strings.formatStringFromName("offlineApps.ask", [requestor], 1);
let message = strings.formatStringFromName("offlineApps.ask", [requestor]);
let options = { checkbox: Strings.browser.GetStringFromName("offlineApps.dontAskAgain") };
NativeWindow.doorhanger.show(message, notificationID, buttons, tab.id, options);
},

View File

@ -134,7 +134,7 @@ var RemoteDebugger = {
let msg = Strings.browser.formatStringFromName("remoteIncomingPromptTCP", [
session.client.host,
session.client.port,
], 2);
]);
let scan = Strings.browser.GetStringFromName("remoteIncomingPromptScan");
let scanAndRemember = Strings.browser.GetStringFromName("remoteIncomingPromptScanAndRemember");
let deny = Strings.browser.GetStringFromName("remoteIncomingPromptDeny");

View File

@ -392,7 +392,7 @@ var Addons = {
detailItem.querySelector(".version").textContent = addon.version;
detailItem.querySelector(".description-full").textContent = addon.description;
detailItem.querySelector(".status-uninstalled").textContent =
gStringBundle.formatStringFromName("addonStatus.uninstalled", [addon.name], 1);
gStringBundle.formatStringFromName("addonStatus.uninstalled", [addon.name]);
let updateBtn = document.getElementById("update-btn");
if (this._addonHasUpdate(addon)) {

View File

@ -1300,7 +1300,7 @@ var BrowserApp = {
if (isPrivate) {
message = Strings.browser.GetStringFromName("privateClosedMessage.message");
} else if (title) {
message = Strings.browser.formatStringFromName("undoCloseToast.message", [title], 1);
message = Strings.browser.formatStringFromName("undoCloseToast.message", [title]);
} else {
message = Strings.browser.GetStringFromName("undoCloseToast.messageDefault");
}
@ -3268,7 +3268,7 @@ ChromeUtils.defineModuleGetter(this, "PageActions",
let [name, script, exprt] = item;
XPCOMUtils.defineLazyGetter(NativeWindow, name, () => {
var err = Strings.browser.formatStringFromName("nativeWindow.deprecated", ["NativeWindow." + name, script], 2);
var err = Strings.browser.formatStringFromName("nativeWindow.deprecated", ["NativeWindow." + name, script]);
Cu.reportError(err);
let sandbox = {};
@ -5091,7 +5091,7 @@ var XPInstallObserver = {
buttons = [strings.GetStringFromName("unsignedAddonsDisabled.dismiss")];
(data) => {};
} else {
message = strings.formatStringFromName("xpinstallDisabledMessage2", [brandShortName, host], 2);
message = strings.formatStringFromName("xpinstallDisabledMessage2", [brandShortName, host]);
buttons = [
strings.GetStringFromName("xpinstallDisabledButton"),
strings.GetStringFromName("unsignedAddonsDisabled.dismiss"),
@ -5118,7 +5118,7 @@ var XPInstallObserver = {
let message;
if (host) {
// We have a host which asked for the install.
message = strings.formatStringFromName("xpinstallPromptWarning2", [brandShortName, host], 2);
message = strings.formatStringFromName("xpinstallPromptWarning2", [brandShortName, host]);
} else {
// Without a host we address the add-on as the initiator of the install.
let addon = null;
@ -5127,10 +5127,10 @@ var XPInstallObserver = {
}
if (addon) {
// We have an addon name, show the regular message.
message = strings.formatStringFromName("xpinstallPromptWarningLocal", [brandShortName, addon], 2);
message = strings.formatStringFromName("xpinstallPromptWarningLocal", [brandShortName, addon]);
} else {
// We don't have an addon name, show an alternative message.
message = strings.formatStringFromName("xpinstallPromptWarningDirect", [brandShortName], 1);
message = strings.formatStringFromName("xpinstallPromptWarningDirect", [brandShortName]);
}
}
@ -5158,7 +5158,7 @@ var XPInstallObserver = {
new Prompt({
window: window,
title: Strings.browser.GetStringFromName("addonError.titleBlocked"),
message: strings.formatStringFromName("xpinstallPromptWarningDirect", [brandShortName], 1),
message: strings.formatStringFromName("xpinstallPromptWarningDirect", [brandShortName]),
buttons: [strings.GetStringFromName("unsignedAddonsDisabled.dismiss")],
}).show((data) => {});
break;
@ -5455,7 +5455,7 @@ var IndexedDB = {
let message, responseTopic;
if (topic == this._permissionsPrompt) {
message = strings.formatStringFromName("offlineApps.ask", [host], 1);
message = strings.formatStringFromName("offlineApps.ask", [host]);
responseTopic = this._permissionsResponse;
}
@ -5793,7 +5793,7 @@ var IdentityHandler = {
result.secure = true;
let iData = this.getIdentityData();
result.verifier = Strings.browser.formatStringFromName("identity.identified.verifier", [iData.caOrg], 1);
result.verifier = Strings.browser.formatStringFromName("identity.identified.verifier", [iData.caOrg]);
// If the cert is identified, then we can populate the results with credentials
if (aState & Ci.nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL) {
@ -5805,7 +5805,7 @@ var IdentityHandler = {
supplemental += iData.city + "\n";
}
if (iData.state && iData.country) {
supplemental += Strings.browser.formatStringFromName("identity.identified.state_and_country", [iData.state, iData.country], 2);
supplemental += Strings.browser.formatStringFromName("identity.identified.state_and_country", [iData.state, iData.country]);
result.country = iData.country;
} else if (iData.state) { // State only
supplemental += iData.state;
@ -6025,7 +6025,7 @@ var SearchEngines = {
try {
await Services.search.addEngine(engine.url, engine.iconURL, false);
// Display a toast confirming addition of new search engine.
Snackbars.show(Strings.browser.formatStringFromName("alertSearchEngineAddedToast", [engine.title], 1), Snackbars.LENGTH_LONG);
Snackbars.show(Strings.browser.formatStringFromName("alertSearchEngineAddedToast", [engine.title]), Snackbars.LENGTH_LONG);
} catch (ex) {
let code = ex.result;
let errorMessage;
@ -6037,7 +6037,7 @@ var SearchEngines = {
errorMessage = "alertSearchEngineErrorToast";
}
Snackbars.show(Strings.browser.formatStringFromName(errorMessage, [engine.title], 1), Snackbars.LENGTH_LONG);
Snackbars.show(Strings.browser.formatStringFromName(errorMessage, [engine.title]), Snackbars.LENGTH_LONG);
}
},
@ -6170,7 +6170,7 @@ var SearchEngines = {
}
await Services.search.addEngineWithDetails(name, data, null, null, method, formURL);
Snackbars.show(Strings.browser.formatStringFromName("alertSearchEngineAddedToast", [name], 1), Snackbars.LENGTH_LONG);
Snackbars.show(Strings.browser.formatStringFromName("alertSearchEngineAddedToast", [name]), Snackbars.LENGTH_LONG);
let engine = Services.search.getEngineByName(name);
engine.wrappedJSObject._queryCharset = charset;
@ -6304,7 +6304,7 @@ var ExternalApps = {
if (uri)
apps = HelperApps.getAppsForUri(uri);
return apps.length == 1 ? Strings.browser.formatStringFromName("helperapps.openWithApp2", [apps[0].name], 1) :
return apps.length == 1 ? Strings.browser.formatStringFromName("helperapps.openWithApp2", [apps[0].name]) :
Strings.browser.GetStringFromName("helperapps.openWithList2");
}, this.filter, this.openExternal);
},

View File

@ -141,11 +141,11 @@ var AboutNetErrorListener = {
msg2 = nss_error_id_str;
}
let msg = gPipNSSBundle.formatStringFromName("SSLConnectionErrorPrefix2",
[hostString, msg2], 2);
[hostString, msg2]);
if (nss_error_id_str) {
msg += gPipNSSBundle.formatStringFromName("certErrorCodePrefix3",
[nss_error_id_str], 1);
[nss_error_id_str]);
}
return msg;
},
@ -183,7 +183,7 @@ var AboutCertErrorListener = {
_setTechDetailsMsgPart1(hostString, securityInfo, technicalInfo, doc) {
let msg = gPipNSSBundle.formatStringFromName("certErrorIntro",
[hostString], 1);
[hostString]);
msg += "\n\n";
if (securityInfo.isUntrusted && !securityInfo.serverCert.isSelfSigned) {
@ -208,7 +208,7 @@ var AboutCertErrorListener = {
// This error code currently only exists for the Symantec distrust, we may need to adjust
// it to fit other distrusts later.
case MOZILLA_PKIX_ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED:
msg += gPipNSSBundle.formatStringFromName("certErrorTrust_Symantec", [hostString], 1) + "\n";
msg += gPipNSSBundle.formatStringFromName("certErrorTrust_Symantec", [hostString]) + "\n";
break;
case SEC_ERROR_UNTRUSTED_CERT:
default:
@ -250,7 +250,7 @@ var AboutCertErrorListener = {
let introContent = doc.getElementById("introContent");
let description = doc.createElement("p");
description.textContent = gPipNSSBundle.formatStringFromName(
"certErrorSymantecDistrustDescription", [hostString], 1);
"certErrorSymantecDistrustDescription", [hostString]);
introContent.append(description);
// The regular "what should I do" message does not make sense in this case.
@ -338,7 +338,7 @@ var AboutCertErrorListener = {
}
} else {
let msg = gPipNSSBundle.formatStringFromName("certErrorMismatch",
[hostString], 1);
[hostString]);
technicalInfo.append(msg + "\n");
}
}
@ -351,15 +351,15 @@ var AboutCertErrorListener = {
if (validity.notBefore) {
if (nowTime > validity.notAfter) {
msg += gPipNSSBundle.formatStringFromName("certErrorExpiredNow",
[validity.notAfterLocalTime, now], 2) + "\n";
[validity.notAfterLocalTime, now]) + "\n";
} else {
msg += gPipNSSBundle.formatStringFromName("certErrorNotYetValidNow",
[validity.notBeforeLocalTime, now], 2) + "\n";
[validity.notBeforeLocalTime, now]) + "\n";
}
} else {
// If something goes wrong, we assume the cert expired.
msg += gPipNSSBundle.formatStringFromName("certErrorExpiredNow",
["", now], 2) + "\n";
["", now]) + "\n";
}
technicalInfo.append(msg);
}
@ -367,7 +367,7 @@ var AboutCertErrorListener = {
// Add link to certificate and error message.
let errorCodeMsg = gPipNSSBundle.formatStringFromName("certErrorCodePrefix3",
[securityInfo.errorCodeString], 1);
[securityInfo.errorCodeString]);
technicalInfo.append(errorCodeMsg);
},

View File

@ -133,7 +133,7 @@ ContentPermissionPrompt.prototype = {
let chromeWin = this.getChromeForRequest(request);
let requestor = (chromeWin.BrowserApp && chromeWin.BrowserApp.manifest) ?
"'" + chromeWin.BrowserApp.manifest.name + "'" : request.principal.URI.host;
let message = browserBundle.formatStringFromName(entityName + ".ask", [requestor], 1);
let message = browserBundle.formatStringFromName(entityName + ".ask", [requestor]);
// desktopNotification doesn't have a checkbox
let options;
if (entityName == "desktopNotification2") {

View File

@ -321,7 +321,7 @@ LoginManagerPrompter.prototype = {
_getLocalizedString: function(key, formatArgs) {
if (formatArgs)
return this._strBundle.pwmgr.formatStringFromName(
key, formatArgs, formatArgs.length);
key, formatArgs);
return this._strBundle.pwmgr.GetStringFromName(key);
},

Some files were not shown because too many files have changed in this diff Show More