Changeset 152380 in webkit


Ignore:
Timestamp:
Jul 3, 2013 4:13:46 PM (11 years ago)
Author:
timothy@apple.com
Message:

Guard remaining calls to decodeURIComponent with a try/catch.

https://bugs.webkit.org/show_bug.cgi?id=118371

Reviewed by Joseph Pecoraro.

  • UserInterface/Main.js:

(WebInspector.displayNameForURL):
(WebInspector.updateWindowTitle):

  • UserInterface/Utilities.js:

(arrayResult):
(queryString):

Location:
trunk/Source/WebInspectorUI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r152374 r152380  
     12013-07-03  Timothy Hatcher  <timothy@apple.com>
     2
     3        Guard remaining calls to decodeURIComponent with a try/catch.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=118371
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        * UserInterface/Main.js:
     10        (WebInspector.displayNameForURL):
     11        (WebInspector.updateWindowTitle):
     12        * UserInterface/Utilities.js:
     13        (arrayResult):
     14        (queryString):
     15
    1162013-07-03  Jessie Berlin  <jberlin@apple.com>
    217
  • trunk/Source/WebInspectorUI/UserInterface/Main.js

    r152141 r152380  
    358358    if (!urlComponents)
    359359        urlComponents = parseURL(url);
     360
    360361    var displayName;
    361362    try {
     
    364365        displayName = urlComponents.lastPathComponent;
    365366    }
     367
    366368    return displayName || WebInspector.displayNameForHost(urlComponents.host) || url;
    367369}
     
    378380    console.assert(mainFrame);
    379381
     382    var urlComponents = mainFrame.mainResource.urlComponents;
     383
     384    var lastPathComponent;
     385    try {
     386        lastPathComponent = decodeURIComponent(urlComponents.lastPathComponent || "");
     387    } catch (e) {
     388        lastPathComponent = urlComponents.lastPathComponent;
     389    }
     390
    380391    // Build a title based on the URL components.
    381     var urlComponents = mainFrame.mainResource.urlComponents;
    382     if (urlComponents.host && urlComponents.lastPathComponent)
    383         var title = this.displayNameForHost(urlComponents.host) + " \u2014 " + decodeURIComponent(urlComponents.lastPathComponent);
     392    if (urlComponents.host && lastPathComponent)
     393        var title = this.displayNameForHost(urlComponents.host) + " \u2014 " + lastPathComponent;
    384394    else if (urlComponents.host)
    385395        var title = this.displayNameForHost(urlComponents.host);
    386     else if (urlComponents.lastPathComponent)
    387         var title = decodeURIComponent(urlComponents.lastPathComponent);
     396    else if (lastPathComponent)
     397        var title = lastPathComponent;
    388398    else
    389399        var title = mainFrame.url;
  • trunk/Source/WebInspectorUI/UserInterface/Utilities.js

    r151453 r152380  
    11711171    function decode(string)
    11721172    {
    1173         // Replace "+" with " " then decode precent encoded values.
    1174         return decodeURIComponent(string.replace(/\+/g, " "));
     1173        try {
     1174            // Replace "+" with " " then decode precent encoded values.
     1175            return decodeURIComponent(string.replace(/\+/g, " "));
     1176        } catch (e) {
     1177            return string;
     1178        }
    11751179    }
    11761180
Note: See TracChangeset for help on using the changeset viewer.