]> git.ipfire.org Git - pbs.git/commitdiff
web: Drop double escaping from text module
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 Oct 2017 17:13:01 +0000 (18:13 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 Oct 2017 17:13:01 +0000 (18:13 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/templates/build-detail.html
src/templates/modules/changelog/entry.html
src/web/__init__.py
src/web/ui_modules.py

index 0d53c15849be33a378123d5e203ccb049453cd11..608aa2a44975c8ec6dafc881914a1f1120814bba 100644 (file)
@@ -90,7 +90,9 @@
                                <div class="span9">
                                        {% if build.type == "release" %}
                                                {% if build.commit %}
-                                                       {% module CommitMessage(build.commit) %}
+                                                       {% apply linkify %}
+                                                               {% module Text(build.commit) %}
+                                                       {% end %}
 
                                                        <hr>
 
index c4a8460f7d93a366a3026a70c57bb78532ec4ceb..f9c2d62ad22710906e843ae13fcc1e4645964bbc 100644 (file)
@@ -28,7 +28,9 @@
 
                        {% if build.type == "release" %}
                                {% if build.commit %}
-                                       {% module CommitMessage(build.commit) %}
+                                       {% apply linkify %}
+                                               {% module Text(build.commit) %}
+                                       {% end %}
 
                                        <hr>
 
index 754b0b5281e0cdb2044245ed83a03bebbb85317e..a6c28ff682c0f1c0ea88a59cb2c1c420e7b6b0ee 100644 (file)
@@ -73,7 +73,6 @@ class Application(tornado.web.Application):
                                # Packages
                                "PackagesDependencyTable" : ui_modules.PackagesDependencyTableModule,
 
-                               "CommitMessage"      : ui_modules.CommitMessageModule,
                                "CommitsTable"       : ui_modules.CommitsTableModule,
                                "JobsBoxes"          : ui_modules.JobsBoxesModule,
                                "JobState"           : ui_modules.JobStateModule,
index ed6c79d281c40dc54cff727b40b536238d62ff2e..e8b809c8abd78864ccdff5c567ff9d29f7c3ab84 100644 (file)
@@ -8,9 +8,9 @@ import math
 import pytz
 import re
 import string
-import tornado.escape
 import tornado.web
 
+from .. import sources
 from .. import users
 from ..constants import *
 
@@ -35,14 +35,12 @@ class TextModule(UIModule):
                        yield paragraph.replace("\n", " ")
 
        def render(self, text, pre=False, remove_linebreaks=True):
+               if isinstance(text, sources.Commit):
+                       text = self._get_commit_message(text)
+
                if remove_linebreaks:
                        text = text.replace("\n", " ")
 
-               # Escape the text and create make urls clickable.
-               text = tornado.escape.xhtml_escape(text)
-               text = tornado.escape.linkify(text, shorten=True,
-                       extra_params="target=\"_blank\" rel=\"noopener\"")
-
                # Search for bug ids that need to be linked to bugzilla
                text = re.sub(self.BUGZILLA_PATTERN, self._bugzilla_repl, text, re.I|re.U)
 
@@ -65,15 +63,10 @@ class TextModule(UIModule):
        def _cve_repl(self, m):
                return self.LINK % ("http://cve.mitre.org/cgi-bin/cvename.cgi?name=%s" % m.group(1), m.group(0))
 
+       def _get_commit_message(self, commit):
+               text = (commit.subject, commit.message)
 
-class CommitMessageModule(TextModule):
-       def render(self, commit):
-               s = "h5. %s\n\n" % commit.subject
-
-               paragraphs = self.split_paragraphs(commit.message)
-               s += "\n\n".join(paragraphs)
-
-               return TextModule.render(self, s, remove_linebreaks=False)
+               return "\n\n".join(text)
 
 
 class ModalModule(UIModule):