Closed Bug 1686907 Opened 4 years ago Closed 4 years ago

$' is replaced to Mozilla Firefox in titles

Categories

(Firefox :: Tabbed Browser, defect)

Firefox 84
defect

Tracking

()

VERIFIED FIXED
86 Branch
Tracking Status
firefox-esr78 --- wontfix
firefox84 --- wontfix
firefox85 --- verified
firefox86 --- verified

People

(Reporter: mzfilin, Assigned: Gijs)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

Attached image Screenshot

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0

Steps to reproduce:

Follow this link and look to the title: https://stackoverflow.com/questions/36587660/in-a-bash-script-what-would-0-evaluate-to-and-why

Actual results:

In page titles $' is replaced to "Mozilla Firefox". Sometimes it is really annoying. For example: https://stackoverflow.com/questions/36587660/in-a-bash-script-what-would-0-evaluate-to-and-why

Expected results:

$' should have left as-is.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → Widget: Gtk
Product: Firefox → Core

I can repro, and this is done from JS code:

Thread 1 hit Breakpoint 2, mozilla::dom::Document::SetTitle (this=0x7f23203d4000, aTitle=..., aRv=...) at /home/emilio/src/moz/gecko-2/dom/base/Document.cpp:8610
8610	  Element* rootElement = GetRootElement();
(rr) p aTitle
$9 = (const nsAString &) @0x7fff177ea058: {<mozilla::detail::nsTStringRepr<char16_t>> = {mData = 0x7f230dd91248 u"1686907 -  — Nightly is replaced to Mozilla Firefox in titles — Nightly", mLength = 71, 
    mDataFlags = (mozilla::detail::StringDataFlags::TERMINATED | mozilla::detail::StringDataFlags::REFCOUNTED), mClassFlags = mozilla::detail::StringClassFlags::INLINE}, }
(rr) p DumpJSStack()
0 updateTitlebar() ["chrome://browser/content/tabbrowser.js":981:28]
    this = [object Object]
1 _setTabLabel(aTab = "[object XULElement]", aLabel = ""1686907 - $' is replaced to Mozilla Firefox in titles"", (destructured parameter) = "[object Object]") ["chrome://browser/content/tabbrowser.js":1539:13]
    this = [object Object]
2 setTabTitle(aTab = "[object XULElement]") ["chrome://browser/content/tabbrowser.js":1501:18]
    this = [object Object]
3 _setupEventListeners/<(event = "[object Event]") ["chrome://browser/content/tabbrowser.js":5352:32]

$10 = void
Status: UNCONFIRMED → NEW
Component: Widget: Gtk → Tabbed Browser
Ever confirmed: true
Product: Core → Firefox

Not a recent regression, happens in firefox 80 at least.

77 is good, I bisected a bit more and stoped at:

https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=3334d8dff757051c7a359818e0ceb5ad7852fdbc&tochange=df5bfb667b9d2fee068861b5c6129bcbbff95cce

Because bug 1626842 is in the range and I'm almost sure that's the cause. Gijs, can you take a look?

Flags: needinfo?(gijskruitbosch+bugs)
Regressed by: 1626842
Has Regression Range: --- → yes
Assignee: nobody → gijskruitbosch+bugs
Status: NEW → ASSIGNED
Flags: needinfo?(gijskruitbosch+bugs)

Huh, JavaScript: "CONTENTTITLE -- Foobar".replace("CONTENTTITLE", '$\'') is -- Foobar -- Foobar, lol

(In reply to Emilio Cobos Álvarez (:emilio) from comment #5)

Huh, JavaScript: "CONTENTTITLE -- Foobar".replace("CONTENTTITLE", '$\'') is -- Foobar -- Foobar, lol

yes, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter

title = title.replaceAll("$", "$$$$") I guess? :-)

I should really have remembered because one of my first Mozilla-related patches involved that construct.

In my defense, that was 16 years ago.

(In reply to Emilio Cobos Álvarez (:emilio) from comment #7)

title = title.replaceAll("$", "$$$$") I guess? :-)

There's a more elegant option, I think:

title = foo.replace("CONTENTTITLE", () => title);

Will need a comment, of course...

Comment on attachment 9197354 [details]
Bug 1686907 - fix the window title being affected by JS's 'replace' API treating dollar signs as 'special', r?emilio

Beta/Release Uplift Approval Request

  • User impact if declined: Confusing window titles
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: See webpage from comment 0 (or use this bug) and check the window title contains a dollar sign followed by a single quote (and doesn't contain the brand name several times)

Note that this bug occurs only on Windows and Linux

  • List of other uplifts needed: nope
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Trivial change to a replace call to avoid silly JS behaviour in how it uses the replacement string
  • String changes made/needed: nope
Attachment #9197354 - Flags: approval-mozilla-beta?
Flags: qe-verify+
Pushed by gijskruitbosch@gmail.com: https://hg.mozilla.org/integration/autoland/rev/bb547abea7c6 fix the window title being affected by JS's 'replace' API treating dollar signs as 'special', r=emilio
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 86 Branch
QA Whiteboard: [qa-triaged]

This issue is Verified as Fixed in our latest Nightly build 86.0a1 (2021-01-17) on Windows 10 and Ubuntu 18.04.

Comment on attachment 9197354 [details]
Bug 1686907 - fix the window title being affected by JS's 'replace' API treating dollar signs as 'special', r?emilio

approved for 85 rc1

Attachment #9197354 - Flags: approval-mozilla-beta? → approval-mozilla-release+

This issue is Verified as Fixed in our latest Release Candidate 85.0 on Windows 10 and Ubuntu 18.04.

Removing qe+ flag as it was verified in Comment 16

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: