changeset 8786:5d8bfda01cf5

lib: drop unnecessary safe_str when processing text
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 09 Nov 2020 16:48:34 +0100
parents 6d2b7e320512
children f375751fe3fa
files kallithea/lib/helpers.py kallithea/lib/markup_renderer.py
diffstat 2 files changed, 2 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/helpers.py	Mon Nov 09 17:47:07 2020 +0100
+++ b/kallithea/lib/helpers.py	Mon Nov 09 16:48:34 2020 +0100
@@ -1052,8 +1052,7 @@
     Render plain text with revision hashes and issue references urlified
     and with @mention highlighting.
     """
-    s = safe_str(source)
-    s = urlify_text(s, repo_name=repo_name)
+    s = urlify_text(source, repo_name=repo_name)
     return literal('<div class="formatted-fixed">%s</div>' % s)
 
 
--- a/kallithea/lib/markup_renderer.py	Mon Nov 09 17:47:07 2020 +0100
+++ b/kallithea/lib/markup_renderer.py	Mon Nov 09 16:48:34 2020 +0100
@@ -36,7 +36,7 @@
 from docutils.core import publish_parts
 from docutils.parsers.rst import directives
 
-from kallithea.lib.utils2 import MENTIONS_REGEX, safe_str
+from kallithea.lib.utils2 import MENTIONS_REGEX
 
 
 log = logging.getLogger(__name__)
@@ -156,7 +156,6 @@
         >>> MarkupRenderer.plain('https://example.com/')
         '<br /><a href="https://example.com/">https://example.com/</a>'
         """
-        source = safe_str(source)
         if universal_newline:
             newline = '\n'
             source = newline.join(source.splitlines())
@@ -197,7 +196,6 @@
         </pre></div>
         </td></tr></table>
         """
-        source = safe_str(source)
         try:
             if flavored:
                 source = cls._flavored_markdown(source)
@@ -215,7 +213,6 @@
 
     @classmethod
     def rst(cls, source, safe=True):
-        source = safe_str(source)
         try:
             docutils_settings = dict([(alias, None) for alias in
                                 cls.RESTRUCTUREDTEXT_DISALLOWED_DIRECTIVES])