⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 249061 in webkit


Ignore:
Timestamp:
Aug 23, 2019, 12:25:31 PM (7 years ago)
Author:
Jonathan Bedard
Message:

results.webkit.org: Escape html in changelog
https://bugs.webkit.org/show_bug.cgi?id=201025
<rdar://problem/54564837>

Reviewed by Darin Adler.

  • resultsdbpy/resultsdbpy/view/commit_view.py:

(CommitView.commit): Output a dictionary instead of a JSON encoded string.

  • resultsdbpy/resultsdbpy/view/templates/commit.html: Unpack commits dictionary

directly into a JavaScript dictionary.

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r249059 r249061  
     12019-08-23  Jonathan Bedard  <jbedard@apple.com>
     2
     3        results.webkit.org: Escape html in changelog
     4        https://bugs.webkit.org/show_bug.cgi?id=201025
     5        <rdar://problem/54564837>
     6
     7        Reviewed by Darin Adler.
     8
     9        * resultsdbpy/resultsdbpy/view/commit_view.py:
     10        (CommitView.commit): Output a dictionary instead of a JSON encoded string.
     11        * resultsdbpy/resultsdbpy/view/templates/commit.html: Unpack commits dictionary
     12        directly into a JavaScript dictionary.
     13
    1142019-08-20  Jiewen Tan  <jiewen_tan@apple.com>
    215
  • trunk/Tools/resultsdbpy/resultsdbpy/view/commit_view.py

    r247628 r249061  
    6060            commit=commit,
    6161            repository_ids=repositories,
    62             commits=Commit.Encoder().encode([commit] + [item for lst in siblings.values() for item in lst]),
     62            commits=Commit.Encoder().default([commit] + [item for lst in siblings.values() for item in lst]),
    6363            **kwargs)
    6464
  • trunk/Tools/resultsdbpy/resultsdbpy/view/templates/commit.html

    r247628 r249061  
    4848<script type="module">
    4949import {CommitTable} from '/assets/js/commit.js';
    50 document.getElementById("commitTable").innerHTML = CommitTable({{ commits|safe }}, {{ repository_ids|safe }});
     50
     51function unescapeJinjaText(text) {
     52    return text.replace(/&([^;]+);/g, function(match, encoded) {
     53        switch (encoded) {
     54        case 'amp':
     55            return '&';
     56        case 'gt':
     57            return '>';
     58        case 'lt':
     59            return '<';
     60        case 'quot':
     61            return '"';
     62        default:
     63            if (encoded[0] != '#')
     64                return encoded;
     65            return String.fromCharCode(encoded.substr(1));
     66        }
     67    });
     68}
     69
     70let commits = [
     71{% for commit in commits %}    {
     72    {% for key, value in commit.items() %}
     73        {{ key }}:
     74        {% if 'str' in value.__class__.__name__ %}
     75            unescapeJinjaText('{{ value | replace("\\", "\\\\") | replace("\n", "\\n") }}')
     76        {% else %}
     77            {{ value }}
     78        {% endif %},
     79    {% endfor %}},
     80{% endfor %}];
     81
     82document.getElementById('commitTable').innerHTML = CommitTable(commits, {{ repository|safe }});
    5183</script>
    5284{% endblock %}
Note: See TracChangeset for help on using the changeset viewer.