Closed
Bug 864097
Opened 12 years ago
Closed 12 years ago
Use String.startsWith/contains instead of regexp in browser.js
Categories
(Firefox for Android Graveyard :: General, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 23
People
(Reporter: tetsuharu, Assigned: tetsuharu)
Details
Attachments
(1 file, 3 obsolete files)
7.06 KB,
patch
|
kats
:
review+
|
Details | Diff | Splinter Review |
No description provided.
Assignee | ||
Comment 1•12 years ago
|
||
Assignee | ||
Comment 2•12 years ago
|
||
Assignee | ||
Updated•12 years ago
|
Attachment #740054 -
Flags: review?(bugmail.mozilla)
Comment 3•12 years ago
|
||
Comment on attachment 740054 [details] [diff] [review]
patch v1
Review of attachment 740054 [details] [diff] [review]:
-----------------------------------------------------------------
This looks fine to me (except for the one comment below).
::: mobile/android/chrome/content/browser.js
@@ +3231,5 @@
> let tabURL = this.browser.currentURI.specIgnoringRef;
> if (article == null || (article.url != tabURL)) {
> // Don't clear the article for about:reader pages since we want to
> // use the article from the previous page
> + if (!tabURL.startsWith("about:reader"))
The regex that this replaced is case-insensitive. I don't know if tabURL can be uppercase or not. Please verify either way (and correct if necessary) before landing this.
Attachment #740054 -
Flags: review?(bugmail.mozilla) → review+
Assignee | ||
Comment 4•12 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #3)
>
> ::: mobile/android/chrome/content/browser.js
> @@ +3231,5 @@
> > let tabURL = this.browser.currentURI.specIgnoringRef;
> > if (article == null || (article.url != tabURL)) {
> > // Don't clear the article for about:reader pages since we want to
> > // use the article from the previous page
> > + if (!tabURL.startsWith("about:reader"))
>
> The regex that this replaced is case-insensitive. I don't know if tabURL can
> be uppercase or not. Please verify either way (and correct if necessary)
> before landing this.
Thank you for speedy review!
How about the new patch?
Attachment #740054 -
Attachment is obsolete: true
Attachment #740315 -
Flags: review?(bugmail.mozilla)
Comment 5•12 years ago
|
||
Comment on attachment 740315 [details] [diff] [review]
patch v2
Review of attachment 740315 [details] [diff] [review]:
-----------------------------------------------------------------
::: mobile/android/chrome/content/browser.js
@@ +3034,5 @@
> // Attach a listener to watch for "click" events bubbling up from error
> // pages and other similar page. This lets us fix bugs like 401575 which
> // require error page UI to do privileged things, without letting error
> // pages have any privilege themselves.
> + if (target.documentURI.startsWith("about:")) {
I'm having second thoughts about this. If target.documentURI doesn't exist (is undefined or null) then the old code would return false but the new code will throw an error. I don't know if this happens in practice, but I'm not the right person to review this.
Attachment #740315 -
Flags: review?(bugmail.mozilla) → review?(mark.finkle)
Comment 6•12 years ago
|
||
Comment on attachment 740315 [details] [diff] [review]
patch v2
Looks like nsStandardURL will lowercase the scheme and the host, so we do not need to lowercase "about:xxx" because "about" is the scheme and "xxx" is the host.
Also, nsDocument::GetDocumentURL appears to always return a string, truncated or filled with a URL spec.
>diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js
>- if (/^about:/.test(target.documentURI)) {
>+ if (target.documentURI.startsWith("about:")) {
We should be a bit more selective here. This block should only be executed for error pages, which should mean:
/^about:(neterror|certerror|blocked)/
I see desktop has a slightly different condition:
http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser.js#4259
Since ErrorPageEventHandler only cares about "about:certerror" and "about:blocked" let's just check from them explicitly:
let docURI = targetdocumentURI;
if (docURI.startsWith("about:certerror") || docURI.startsWith("about:blocked")) {
Also use docURI in the :about:reader" test that's just below the error page test
>- if (!/^about:reader/i.test(tabURL))
>+ if (!tabURL.toLowerCase().startsWith("about:reader"))
Should be fine to drop the toLowerCase
r+ with those changes
Attachment #740315 -
Flags: review?(mark.finkle) → review+
Assignee | ||
Comment 7•12 years ago
|
||
Thank you for your comments, Mark.
And just to be safe, I'm confirming this patch on try: https://tbpl.mozilla.org/?tree=Try&rev=9e7e0ce61bb0
Attachment #740315 -
Attachment is obsolete: true
Attachment #740790 -
Flags: review?(bugmail.mozilla)
Comment 8•12 years ago
|
||
Comment on attachment 740790 [details] [diff] [review]
patch v3
>diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js
>+ let docURI = target.documentURI;
>+ if (docURI.startsWith("about:certerror") || docURI.startsWith("about:blocked")) {
> this.browser.addEventListener("click", ErrorPageEventHandler, true);
> let listener = function() {
> this.browser.removeEventListener("click", ErrorPageEventHandler, true);
> this.browser.removeEventListener("pagehide", listener, true);
> }.bind(this);
>
> this.browser.addEventListener("pagehide", listener, true);
> }
>
>- if (/^about:reader/.test(target.documentURI))
>+ if (target.documentURI.startsWith("about:reader"))
Might as well use "docURI" here instaed of "target.documentURI"
Assignee | ||
Comment 9•12 years ago
|
||
(In reply to Mark Finkle (:mfinkle) from comment #8)
> Comment on attachment 740790 [details] [diff] [review]
> patch v3
>
> >diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js
> >+ let docURI = target.documentURI;
> >+ if (docURI.startsWith("about:certerror") || docURI.startsWith("about:blocked")) {
> > this.browser.addEventListener("click", ErrorPageEventHandler, true);
> > let listener = function() {
> > this.browser.removeEventListener("click", ErrorPageEventHandler, true);
> > this.browser.removeEventListener("pagehide", listener, true);
> > }.bind(this);
> >
> > this.browser.addEventListener("pagehide", listener, true);
> > }
> >
> >- if (/^about:reader/.test(target.documentURI))
> >+ if (target.documentURI.startsWith("about:reader"))
>
> Might as well use "docURI" here instaed of "target.documentURI"
Oops!
Assignee | ||
Comment 10•12 years ago
|
||
Attachment #740790 -
Attachment is obsolete: true
Attachment #740790 -
Flags: review?(bugmail.mozilla)
Attachment #740804 -
Flags: review?(bugmail.mozilla)
Updated•12 years ago
|
Attachment #740804 -
Flags: review?(bugmail.mozilla) → review+
Assignee | ||
Updated•12 years ago
|
Keywords: checkin-needed
Comment 11•12 years ago
|
||
Assignee: nobody → saneyuki.s.snyk
Keywords: checkin-needed
Comment 12•12 years ago
|
||
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 23
Comment 13•12 years ago
|
||
(In reply to Mark Finkle (:mfinkle) from comment #6)
> Looks like nsStandardURL will lowercase the scheme and the host, so we do
> not need to lowercase "about:xxx" because "about" is the scheme and "xxx" is
> the host.
nsStandardURL does not handle "about:" URIs. nsSimpleURI does.
Comment 14•12 years ago
|
||
(In reply to Masatoshi Kimura [:emk] from comment #13)
> (In reply to Mark Finkle (:mfinkle) from comment #6)
> > Looks like nsStandardURL will lowercase the scheme and the host, so we do
> > not need to lowercase "about:xxx" because "about" is the scheme and "xxx" is
> > the host.
>
> nsStandardURL does not handle "about:" URIs. nsSimpleURI does.
Which does seem to lowercase the scheme.
Comment 15•12 years ago
|
||
What about the opaque part? "about:Blank" wasn't lowercased.
Comment 16•12 years ago
|
||
(In reply to Masatoshi Kimura [:emk] from comment #15)
> What about the opaque part? "about:Blank" wasn't lowercased.
I'm not too worried about it. Humans don't normally type those. If we find bugs, we'll fix them.
Updated•5 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•