From: Michael Tremer Date: Thu, 26 Oct 2017 17:13:01 +0000 (+0100) Subject: web: Drop double escaping from text module X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ffc539a7ed69075389ee781fef81a73f68f1018;p=pbs.git web: Drop double escaping from text module Signed-off-by: Michael Tremer --- diff --git a/src/templates/build-detail.html b/src/templates/build-detail.html index 0d53c158..608aa2a4 100644 --- a/src/templates/build-detail.html +++ b/src/templates/build-detail.html @@ -90,7 +90,9 @@
{% if build.type == "release" %} {% if build.commit %} - {% module CommitMessage(build.commit) %} + {% apply linkify %} + {% module Text(build.commit) %} + {% end %}
diff --git a/src/templates/modules/changelog/entry.html b/src/templates/modules/changelog/entry.html index c4a8460f..f9c2d62a 100644 --- a/src/templates/modules/changelog/entry.html +++ b/src/templates/modules/changelog/entry.html @@ -28,7 +28,9 @@ {% if build.type == "release" %} {% if build.commit %} - {% module CommitMessage(build.commit) %} + {% apply linkify %} + {% module Text(build.commit) %} + {% end %}
diff --git a/src/web/__init__.py b/src/web/__init__.py index 754b0b52..a6c28ff6 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -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, diff --git a/src/web/ui_modules.py b/src/web/ui_modules.py index ed6c79d2..e8b809c8 100644 --- a/src/web/ui_modules.py +++ b/src/web/ui_modules.py @@ -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):