Changeset 204510 in webkit


Ignore:
Timestamp:
Aug 16, 2016 9:57:27 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: Visual Styles: "Text -> Content" isn't escaped
https://bugs.webkit.org/show_bug.cgi?id=158271

Patch by Devin Rousso <Devin Rousso> on 2016-08-16
Reviewed by Timothy Hatcher.

  • UserInterface/Base/Utilities.js:

(String.prototype.hasMatchingEscapedQuotes):
Checks that the given string has property escaped quotes (single or double).

  • UserInterface/Views/VisualStyleBasicInput.js:

(WebInspector.VisualStyleBasicInput):
(WebInspector.VisualStyleBasicInput.prototype._handleInputElementInput):

Location:
trunk/Source/WebInspectorUI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r204507 r204510  
     12016-08-16  Devin Rousso  <dcrousso+webkit@gmail.com>
     2
     3        Web Inspector: Visual Styles: "Text -> Content" isn't escaped
     4        https://bugs.webkit.org/show_bug.cgi?id=158271
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * UserInterface/Base/Utilities.js:
     9        (String.prototype.hasMatchingEscapedQuotes):
     10        Checks that the given string has property escaped quotes (single or double).
     11
     12        * UserInterface/Views/VisualStyleBasicInput.js:
     13        (WebInspector.VisualStyleBasicInput):
     14        (WebInspector.VisualStyleBasicInput.prototype._handleInputElementInput):
     15
    1162016-08-16  Joseph Pecoraro  <pecoraro@apple.com>
    217
  • trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js

    r201778 r204510  
    918918});
    919919
     920Object.defineProperty(String.prototype, "hasMatchingEscapedQuotes",
     921{
     922    value: function()
     923    {
     924        return /^\"(?:[^\"\\]|\\.)*\"$/.test(this) || /^\'(?:[^\'\\]|\\.)*\'$/.test(this);
     925    }
     926});
     927
    920928Object.defineProperty(Math, "roundTo",
    921929{
  • trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleBasicInput.js

    r194673 r204510  
    3333        this._inputElement.spellcheck = false;
    3434        this._inputElement.setAttribute("placeholder", placeholder || "");
    35         this._inputElement.addEventListener("input", this._handleInputElementInput.bind(this));
     35        this._inputElement.addEventListener("input", this.debounce(500)._handleInputElementInput);
    3636    }
    3737
     
    6060    _handleInputElementInput(event)
    6161    {
     62        let value = this.value;
     63        if (value && value.trim().length) {
     64            let validItems = [];
     65            for (let item of value.split(/([^\"\'\s]+|\"[^\"]*\"|\'[^\']*\')/)) {
     66                if (!item.length || (!item.hasMatchingEscapedQuotes() && !/^[\w\s\-\.\(\)]+$/.test(item)))
     67                    continue;
     68
     69                validItems.push(item);
     70            }
     71
     72            this.value = validItems.filter(item => item.trim().length).join(" ");
     73        }
     74
    6275        this._valueDidChange();
    6376    }
Note: See TracChangeset for help on using the changeset viewer.