You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2022/04/13 17:13:41 UTC

[allura] branch master updated: [#8425] upgrade jinja to 3.1.1

This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git


The following commit(s) were added to refs/heads/master by this push:
     new 2a7c6047f [#8425] upgrade jinja to 3.1.1
2a7c6047f is described below

commit 2a7c6047f090ed19b7489bc9d15fcbbce664031c
Author: Kenton Taylor <kt...@slashdotmedia.com>
AuthorDate: Thu Apr 7 13:52:49 2022 +0000

    [#8425] upgrade jinja to 3.1.1
---
 Allura/allura/controllers/project.py      |  5 +++--
 Allura/allura/lib/app_globals.py          |  2 +-
 Allura/allura/lib/helpers.py              |  2 +-
 Allura/allura/lib/macro.py                |  3 ++-
 Allura/allura/lib/phone/nexmo.py          |  3 ++-
 Allura/allura/lib/search.py               | 15 ++++++++-------
 Allura/allura/lib/widgets/user_profile.py |  4 ++--
 Allura/allura/model/discuss.py            |  3 ++-
 Allura/allura/tests/test_globals.py       |  2 +-
 Allura/allura/tests/test_helpers.py       |  2 +-
 ForgeTracker/forgetracker/model/ticket.py |  9 +++++----
 requirements.txt                          |  4 ++--
 12 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 05dbb2b9e..827c58bd9 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -29,6 +29,7 @@ from tg import tmpl_context as c, app_globals as g
 from paste.deploy.converters import asbool
 from webob import exc
 import jinja2
+import markupsafe
 import pymongo
 
 from ming.utils import LazyProperty
@@ -175,7 +176,7 @@ class NeighborhoodController:
             session['phone_verification.number_hash'] = number_hash
             session.save()
         if 'error' in result:
-            result['error'] = jinja2.Markup.escape(result['error'])
+            result['error'] = markupsafe.Markup.escape(result['error'])
             result['error'] = h.really_unicode(result['error'])
         return result
 
@@ -187,7 +188,7 @@ class NeighborhoodController:
         number_hash = session.get('phone_verification.number_hash')
         res = p.check_phone_verification(c.user, request_id, pin, number_hash)
         if 'error' in res:
-            res['error'] = jinja2.Markup.escape(res['error'])
+            res['error'] = markupsafe.Markup.escape(res['error'])
             res['error'] = h.really_unicode(res['error'])
         return res
 
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 8487d6d3e..4a958b19d 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -48,7 +48,7 @@ from ming.odm import session, MappedClass
 import ew as ew_core
 import ew.jinja2_ew as ew
 from ming.utils import LazyProperty
-from jinja2 import Markup
+from markupsafe import Markup
 
 import allura.tasks.event_tasks
 from allura import model as M
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index f0d00259b..c6ec0e973 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -56,7 +56,7 @@ from tg import response, request
 from tg.decorators import before_validate
 from formencode.variabledecode import variable_decode
 import formencode
-from jinja2 import Markup
+from markupsafe import Markup
 from jinja2.filters import escape, do_filesizeformat
 from jinja2.utils import pass_context
 from paste.deploy.converters import asbool, aslist, asint
diff --git a/Allura/allura/lib/macro.py b/Allura/allura/lib/macro.py
index 0a9155db1..b1af50297 100644
--- a/Allura/allura/lib/macro.py
+++ b/Allura/allura/lib/macro.py
@@ -30,6 +30,7 @@ import six.moves.urllib.error
 
 import oembed
 import jinja2
+import markupsafe
 from operator import attrgetter
 from six.moves.urllib.parse import urlparse, urlunparse
 
@@ -504,6 +505,6 @@ def embed(url=None):
                 embed_url = embed_url.geturl()
             embed_url = embed_url.replace('www.youtube.com', 'www.youtube-nocookie.com')
             html.find('iframe')['src'] = embed_url
-        return jinja2.Markup('<p>%s</p>' % html)
+        return markupsafe.Markup('<p>%s</p>' % html)
 
     return '[[embed url=%s]]' % url
diff --git a/Allura/allura/lib/phone/nexmo.py b/Allura/allura/lib/phone/nexmo.py
index b51be4293..2c3781373 100644
--- a/Allura/allura/lib/phone/nexmo.py
+++ b/Allura/allura/lib/phone/nexmo.py
@@ -22,6 +22,7 @@ import json
 
 import requests
 import jinja2
+import markupsafe
 
 from allura.lib.phone import PhoneService
 from allura.lib.utils import phone_number_hash
@@ -56,7 +57,7 @@ class NexmoPhoneService(PhoneService):
         if code is None or str(code) not in allowed_codes:
             msg = 'Failed sending request to Nexmo'
         if str(code) == '3' and msg.endswith(' number'):
-            msg = jinja2.Markup(
+            msg = markupsafe.Markup(
                 '{}{}{}'.format(
                     cgi.escape(msg),  # escape it just in case Nexmo sent some HTML we don't want through
                     '<br>Make sure you include the country code (see examples above)',
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 7c3346f4d..9f1e94ff6 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -25,6 +25,7 @@ from logging import getLogger
 import bson
 import markdown
 import jinja2
+import markupsafe
 from tg import redirect, url
 from tg import tmpl_context as c, app_globals as g
 from tg import request
@@ -101,7 +102,7 @@ class SearchIndexable:
         # Convert text to plain text (It usually contains markdown markup).
         # To do so, we convert markdown into html, and then strip all html tags.
         text = g.markdown.convert(text)
-        doc['text'] = jinja2.Markup.escape(text).striptags()
+        doc['text'] = markupsafe.Markup.escape(text).striptags()
 
         # convert some date/time field types to str
         # from https://github.com/django-haystack/pysolr/blob/1a8887cb2ce1c30ef9d6570704254b4520f8a959/pysolr.py#L692
@@ -309,13 +310,13 @@ def search_app(q='', fq=None, app=True, **kw):
                 title = h.get_first(m, 'title')
                 text = h.get_first(m, 'text')
                 if title:
-                    title = (jinja2.escape(title)
-                                   .replace('#ALLURA-HIGHLIGHT-START#', jinja2.Markup('<strong>'))
-                                   .replace('#ALLURA-HIGHLIGHT-END#', jinja2.Markup('</strong>')))
+                    title = (markupsafe.escape(title)
+                                   .replace('#ALLURA-HIGHLIGHT-START#', markupsafe.Markup('<strong>'))
+                                   .replace('#ALLURA-HIGHLIGHT-END#', markupsafe.Markup('</strong>')))
                 if text:
-                    text = (jinja2.escape(text)
-                                  .replace('#ALLURA-HIGHLIGHT-START#', jinja2.Markup('<strong>'))
-                                  .replace('#ALLURA-HIGHLIGHT-END#', jinja2.Markup('</strong>')))
+                    text = (markupsafe.escape(text)
+                                  .replace('#ALLURA-HIGHLIGHT-START#', markupsafe.Markup('<strong>'))
+                                  .replace('#ALLURA-HIGHLIGHT-END#', markupsafe.Markup('</strong>')))
                 doc['title_match'] = title
                 doc['text_match'] = text or h.get_first(doc, 'text')
                 return doc
diff --git a/Allura/allura/lib/widgets/user_profile.py b/Allura/allura/lib/widgets/user_profile.py
index 727ae4f76..830d23709 100644
--- a/Allura/allura/lib/widgets/user_profile.py
+++ b/Allura/allura/lib/widgets/user_profile.py
@@ -20,7 +20,7 @@ import re
 
 import ew as ew_core
 import ew.jinja2_ew as ew
-from jinja2 import Markup
+from markupsafe import Markup
 from paste.deploy.converters import asbool
 import tg
 from tg import app_globals as g
@@ -123,7 +123,7 @@ class SectionBase:
         and the :attr:`template`, if :meth:`check_display` returns True.
 
         If overridden or this base class is not used, this method should
-        return either plain text (which will be escaped) or a `jinja2.Markup`
+        return either plain text (which will be escaped) or a `marksupsafe.Markup`
         instance.
         """
         if not self.check_display():
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index e6433f5ae..6709f6e52 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -21,6 +21,7 @@ from datetime import datetime
 import typing
 
 import jinja2
+import markupsafe
 import pymongo
 from pymongo.errors import DuplicateKeyError
 from tg import tmpl_context as c, app_globals as g
@@ -588,7 +589,7 @@ class Post(Message, VersionedArtifact, ActivityObject, ReactableArtifact):
         # For activity summary, convert Post text to html,
         # strip all tags, and truncate
         LEN = 500
-        summary = jinja2.Markup.escape(
+        summary = markupsafe.Markup.escape(
             g.markdown.cached_convert(self, 'text')).striptags()
         if len(summary) > LEN:
             split = max(summary.find(' ', LEN), LEN)
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 6d1f51e8f..3b1334915 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -880,7 +880,7 @@ class TestCachedMarkdown(unittest.TestCase):
 
     @patch.dict('allura.lib.app_globals.config', markdown_cache_threshold='-0.01')
     def test_valid_cache(self):
-        from jinja2 import Markup
+        from markupsafe import Markup
         self.md.cached_convert(self.post, 'text')
         with patch.object(self.md, 'convert') as convert_func:
             html = self.md.cached_convert(self.post, 'text')
diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index 267b3492b..3c1428586 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -28,7 +28,7 @@ from datadiff import tools as dd
 from webob import Request
 from webob.exc import HTTPUnauthorized
 from ming.orm import ThreadLocalORMSession
-from jinja2 import Markup
+from markupsafe import Markup
 
 from allura import model as M
 from allura.lib import exceptions as exc
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index cf90c3eaa..34aa72e94 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -33,6 +33,7 @@ from pymongo.errors import OperationFailure
 from tg import tmpl_context as c, app_globals as g
 from paste.deploy.converters import aslist, asbool
 import jinja2
+import markupsafe
 
 from ming import schema
 from ming.utils import LazyProperty
@@ -459,7 +460,7 @@ class Globals(MappedClass):
                 # mark changes text as safe, thus it wouldn't be escaped in plain-text emails
                 # html part of email is handled by markdown and it'll be
                 # properly escaped
-                yield (changed_tickets[t_id], jinja2.Markup(changes[t_id]))
+                yield (changed_tickets[t_id], markupsafe.Markup(changes[t_id]))
         mail = dict(
             sender=c.project.app_instance(self.app_config).email_address,
             fromaddr=str(c.user._id),
@@ -482,7 +483,7 @@ class Globals(MappedClass):
                 v = user.display_name if user else v
             head.append(f'- **{cf.label}**: {v}')
         tmpl_context = {'context': c, 'data':
-                        {'header': jinja2.Markup('\n'.join(['Mass edit changing:', ''] + head))}}
+                        {'header': markupsafe.Markup('\n'.join(['Mass edit changing:', ''] + head))}}
         for user in users:
             tmpl_context['data'].update({'changes': changes_iter(user)})
             mail.update(dict(
@@ -501,7 +502,7 @@ class Globals(MappedClass):
                         self.app_config.options.get('TicketMonitoringType') ==
                         'AllTicketChanges'):
                     visible_changes.append(
-                        (changed_tickets[t_id], jinja2.Markup(changes[t_id])))
+                        (changed_tickets[t_id], markupsafe.Markup(changes[t_id])))
             if visible_changes:
                 tmpl_context['data'].update({'changes': visible_changes})
                 mail.update(dict(
@@ -678,7 +679,7 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
     def link_text(self):
         text = super().link_text()
         if self.is_closed:
-            return jinja2.Markup('<s>') + text + jinja2.Markup('</s>')
+            return markupsafe.Markup('<s>') + text + markupsafe.Markup('</s>')
         return text
 
     @property
diff --git a/requirements.txt b/requirements.txt
index d88550a5e..24c1b5352 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -36,7 +36,7 @@ decorator==5.1.0
     # via -r requirements.in
 docutils==0.17.1
     # via pypeline
-easywidgets==0.3.6
+easywidgets==0.3.7
     # via -r requirements.in
 emoji==1.5.0
     # via -r requirements.in
@@ -73,7 +73,7 @@ inflection==0.5.1
     # via profanityfilter
 iso8601==0.1.16
     # via colander
-jinja2==3.0.2
+jinja2==3.1.1
     # via -r requirements.in
 markdown==3.3.6
     # via