Bug 369778 - Fix two RegExps that expect an unmatched capture group expands to the empty string, not to |undefined|. r=dolske
authorJeff Walden <jwalden@mit.edu>
Fri, 25 Jul 2014 14:34:10 -0700
changeset 196213 eb01c53fd87978dc635fd38336d126b0e3a03a9c
parent 196212 22cfcffb5a8b250f27e763d694ea8bf858a60a90
child 196214 86f2f0f56aea51b7f7552d38a2e1eff11d04d691
push id27208
push usercbook@mozilla.com
push dateMon, 28 Jul 2014 13:33:20 +0000
treeherdermozilla-central@70b3fc807a70 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs369778
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 369778 - Fix two RegExps that expect an unmatched capture group expands to the empty string, not to |undefined|. r=dolske
toolkit/components/prompts/src/CommonDialog.jsm
--- a/toolkit/components/prompts/src/CommonDialog.jsm
+++ b/toolkit/components/prompts/src/CommonDialog.jsm
@@ -193,20 +193,20 @@ CommonDialog.prototype = {
         // by spaces and/or followed by the ':' character, store the access key and
         // remove the access key placeholder + leading spaces from the label.
         // Otherwise a character preceded by one but not two &s is the access key.
         // Store it and remove the &.
 
         // Note that if you change the following code, see the comment of
         // nsTextBoxFrame::UpdateAccessTitle.
         var accessKey = null;
-        if (/ *\(\&([^&])\)(:)?$/.test(aLabel)) {
+        if (/ *\(\&([^&])\)(:?)$/.test(aLabel)) {
             aLabel = RegExp.leftContext + RegExp.$2;
             accessKey = RegExp.$1;
-        } else if (/^(.*[^&])?\&(([^&]).*$)/.test(aLabel)) {
+        } else if (/^([^&]*)\&(([^&]).*$)/.test(aLabel)) {
             aLabel = RegExp.$1 + RegExp.$2;
             accessKey = RegExp.$3;
         }
 
         // && is the magic sequence to embed an & in your label.
         aLabel = aLabel.replace(/\&\&/g, "&");
         aNode.label = aLabel;