mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 792968 - Replace some regular expression string matches with String.startsWith and replace /^https?/ URI scheme tests with /^https?$/. r=dao
This commit is contained in:
parent
d941f59602
commit
6684ca9137
@ -95,7 +95,7 @@ var FeedHandler = {
|
||||
var feedURI = makeURI(href, document.characterSet);
|
||||
// Use the feed scheme so X-Moz-Is-Feed will be set
|
||||
// The value doesn't matter
|
||||
if (/^https?/.test(feedURI.scheme))
|
||||
if (/^https?$/.test(feedURI.scheme))
|
||||
href = "feed:" + href;
|
||||
this.loadFeed(href, event);
|
||||
},
|
||||
|
@ -8,7 +8,7 @@ var gSafeBrowsing = {
|
||||
setReportPhishingMenu: function() {
|
||||
|
||||
// A phishing page will have a specific about:blocked content documentURI
|
||||
var isPhishingPage = /^about:blocked\?e=phishingBlocked/.test(content.document.documentURI);
|
||||
var isPhishingPage = content.document.documentURI.startsWith("about:blocked?e=phishingBlocked");
|
||||
|
||||
// Show/hide the appropriate menu item.
|
||||
document.getElementById("menu_HelpPopup_reportPhishingtoolmenu")
|
||||
|
@ -735,7 +735,7 @@ var allTabs = {
|
||||
},
|
||||
|
||||
handleEvent: function allTabs_handleEvent(event) {
|
||||
if (/^Tab/.test(event.type)) {
|
||||
if (event.type.startsWith("Tab")) {
|
||||
var tab = event.target;
|
||||
if (event.type != "TabOpen")
|
||||
var preview = this._getPreview(tab);
|
||||
|
@ -2521,13 +2521,13 @@ let BrowserOnClick = {
|
||||
|
||||
// If the event came from an ssl error page, it is probably either the "Add
|
||||
// Exception…" or "Get me out of here!" button
|
||||
if (/^about:certerror/.test(ownerDoc.documentURI)) {
|
||||
if (ownerDoc.documentURI.startsWith("about:certerror")) {
|
||||
this.onAboutCertError(originalTarget, ownerDoc);
|
||||
}
|
||||
else if (/^about:blocked/.test(ownerDoc.documentURI)) {
|
||||
else if (ownerDoc.documentURI.startsWith("about:blocked")) {
|
||||
this.onAboutBlocked(originalTarget, ownerDoc);
|
||||
}
|
||||
else if (/^about:neterror/.test(ownerDoc.documentURI)) {
|
||||
else if (ownerDoc.documentURI.startsWith("about:neterror")) {
|
||||
this.onAboutNetError(originalTarget, ownerDoc);
|
||||
}
|
||||
else if (/^about:home$/i.test(ownerDoc.documentURI)) {
|
||||
@ -4481,7 +4481,7 @@ var TabsProgressListener = {
|
||||
|
||||
if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
|
||||
Components.isSuccessCode(aStatus) &&
|
||||
/^about:/.test(aWebProgress.DOMWindow.document.documentURI)) {
|
||||
aWebProgress.DOMWindow.document.documentURI.startsWith("about:")) {
|
||||
aBrowser.addEventListener("click", BrowserOnClick, true);
|
||||
aBrowser.addEventListener("pagehide", function onPageHide(event) {
|
||||
if (event.target.defaultView.frameElement)
|
||||
|
@ -161,7 +161,7 @@ gImageView.getCellProperties = function(row, col, props) {
|
||||
var item = gImageView.data[row][COL_IMAGE_NODE];
|
||||
if (!checkProtocol(data) ||
|
||||
item instanceof HTMLEmbedElement ||
|
||||
(item instanceof HTMLObjectElement && !/^image\//.test(item.type)))
|
||||
(item instanceof HTMLObjectElement && !item.type.startsWith("image/"))
|
||||
props.AppendElement(this._brokenAtom);
|
||||
|
||||
if (col.element.id == "image-address")
|
||||
@ -945,7 +945,7 @@ function makePreview(row)
|
||||
mimeType = getContentTypeFromHeaders(cacheEntry);
|
||||
|
||||
// if we have a data url, get the MIME type from the url
|
||||
if (!mimeType && /^data:/.test(url)) {
|
||||
if (!mimeType && url.startsWith("data:")) {
|
||||
let dataMimeType = /^data:(image\/[^;,]+)/i.exec(url);
|
||||
if (dataMimeType)
|
||||
mimeType = dataMimeType[1].toLowerCase();
|
||||
@ -987,7 +987,7 @@ function makePreview(row)
|
||||
if ((item instanceof HTMLLinkElement || item instanceof HTMLInputElement ||
|
||||
item instanceof HTMLImageElement ||
|
||||
item instanceof SVGImageElement ||
|
||||
(item instanceof HTMLObjectElement && /^image\//.test(mimeType)) || isBG) && isProtocolAllowed) {
|
||||
(item instanceof HTMLObjectElement && mimeType.startsWith("image/")) || isBG) && isProtocolAllowed) {
|
||||
newImage.setAttribute("src", url);
|
||||
physWidth = newImage.width || 0;
|
||||
physHeight = newImage.height || 0;
|
||||
|
@ -83,7 +83,7 @@ function onLoadPermission()
|
||||
|
||||
var uri = gDocument.documentURIObject;
|
||||
var permTab = document.getElementById("permTab");
|
||||
if(/^https?/.test(uri.scheme)) {
|
||||
if (/^https?$/.test(uri.scheme)) {
|
||||
gPermURI = uri;
|
||||
var hostText = document.getElementById("hostText");
|
||||
hostText.value = gPermURI.host;
|
||||
|
@ -645,7 +645,7 @@
|
||||
<method name="_parseActionUrl">
|
||||
<parameter name="aUrl"/>
|
||||
<body><![CDATA[
|
||||
if (!/^moz-action:/.test(aUrl))
|
||||
if (!aUrl.startsWith("moz-action:"))
|
||||
return null;
|
||||
|
||||
// url is in the format moz-action:ACTION,PARAM
|
||||
@ -1615,7 +1615,7 @@
|
||||
// otherwise just rely on the panel id for common arrowpanels.
|
||||
let type = this._panel.firstChild.getAttribute("popupid") ||
|
||||
this._panel.id;
|
||||
if (/^password-/.test(type))
|
||||
if (type.startsWith("password-"))
|
||||
return "passwords";
|
||||
if (type == "editBookmarkPanel")
|
||||
return "bookmarks";
|
||||
|
@ -12,7 +12,7 @@ function testBrokenCert() {
|
||||
window.removeEventListener("DOMContentLoaded", testBrokenCert, true);
|
||||
|
||||
// Confirm that we are displaying the contributed error page, not the default
|
||||
ok(/^about:certerror/.test(gBrowser.contentDocument.documentURI), "Broken page should go to about:certerror, not about:neterror");
|
||||
ok(gBrowser.contentDocument.documentURI.startsWith("about:certerror"), "Broken page should go to about:certerror, not about:neterror");
|
||||
|
||||
// Confirm that the expert section is collapsed
|
||||
var expertDiv = gBrowser.contentDocument.getElementById("expertContent");
|
||||
|
@ -864,7 +864,7 @@ DownloadsDataItem.prototype = {
|
||||
// The download database may contain targets stored as file URLs or native
|
||||
// paths. This can still be true for previously stored items, even if new
|
||||
// items are stored using their file URL. See also bug 239948 comment 12.
|
||||
if (/^file:/.test(this.file)) {
|
||||
if (this.file.startsWith("file:")) {
|
||||
// Assume the file URL we obtained from the downloads database or from the
|
||||
// "spec" property of the target has the UTF-8 charset.
|
||||
let fileUrl = NetUtil.newURI(this.file).QueryInterface(Ci.nsIFileURL);
|
||||
|
@ -1340,7 +1340,7 @@ FeedWriter.prototype = {
|
||||
_setFaviconForWebReader:
|
||||
function FW__setFaviconForWebReader(aReaderUrl, aMenuItem) {
|
||||
var readerURI = makeURI(aReaderUrl);
|
||||
if (!/^https?/.test(readerURI.scheme)) {
|
||||
if (!/^https?$/.test(readerURI.scheme)) {
|
||||
// Don't try to get a favicon for non http(s) URIs.
|
||||
return;
|
||||
}
|
||||
|
@ -1425,13 +1425,13 @@ let PlacesControllerDragHelper = {
|
||||
if (ip.isTag && ip.orientation == Ci.nsITreeView.DROP_ON &&
|
||||
dragged.type != PlacesUtils.TYPE_X_MOZ_URL &&
|
||||
(dragged.type != PlacesUtils.TYPE_X_MOZ_PLACE ||
|
||||
/^place:/.test(dragged.uri)))
|
||||
dragged.uri.startsWith("place:")))
|
||||
return false;
|
||||
|
||||
// The following loop disallows the dropping of a folder on itself or
|
||||
// on any of its descendants.
|
||||
if (dragged.type == PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER ||
|
||||
/^place:/.test(dragged.uri)) {
|
||||
dragged.uri.startsWith("place:")) {
|
||||
let parentId = ip.itemId;
|
||||
while (parentId != PlacesUtils.placesRootId) {
|
||||
if (dragged.concreteId == parentId || dragged.id == parentId)
|
||||
|
@ -1887,7 +1887,7 @@ var gApplicationsPane = {
|
||||
// that template (i.e. with %s in the template replaced by the URL of the
|
||||
// content being handled).
|
||||
|
||||
if (/^https?/.test(uri.scheme) && this._prefSvc.getBoolPref("browser.chrome.favicons"))
|
||||
if (/^https?$/.test(uri.scheme) && this._prefSvc.getBoolPref("browser.chrome.favicons"))
|
||||
return uri.prePath + "/favicon.ico";
|
||||
|
||||
return "";
|
||||
|
@ -1874,7 +1874,7 @@ var gApplicationsPane = {
|
||||
// they'll only visit URLs derived from that template (i.e. with %s
|
||||
// in the template replaced by the URL of the content being handled).
|
||||
|
||||
if (/^https?/.test(uri.scheme) && this._prefSvc.getBoolPref("browser.chrome.favicons"))
|
||||
if (/^https?$/.test(uri.scheme) && this._prefSvc.getBoolPref("browser.chrome.favicons"))
|
||||
return uri.prePath + "/favicon.ico";
|
||||
|
||||
return "";
|
||||
|
@ -51,7 +51,7 @@
|
||||
url = decodeURIComponent(match[1]);
|
||||
|
||||
// If this is a view-source page, then get then real URI of the page
|
||||
if (/^view-source\:/.test(url))
|
||||
if (url.startsWith("view-source:"))
|
||||
url = url.slice(12);
|
||||
return url;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ function onTabPinned() {
|
||||
|
||||
// with moz-anno:favicon automatically redirects to the default favIcon
|
||||
// if the given url is invalid
|
||||
ok(/^moz-anno:favicon:/.test(iconSrc),
|
||||
ok(iconSrc.startsWith("moz-anno:favicon:"),
|
||||
"The icon url starts with moz-anno:favicon so the default fav icon would be displayed");
|
||||
|
||||
// At this point, as an additional integrity check we could also verify
|
||||
|
Loading…
Reference in New Issue
Block a user