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/11 13:23:19 UTC
[allura] branch kt/8425 updated: fixup! [#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 kt/8425
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/kt/8425 by this push:
new 9048996e1 fixup! [#8425] upgrade jinja to 3.1.1
9048996e1 is described below
commit 9048996e11474514c603d3ba683aa7d23c16e59b
Author: Kenton Taylor <kt...@slashdotmedia.com>
AuthorDate: Mon Apr 11 13:22:41 2022 +0000
fixup! [#8425] upgrade jinja to 3.1.1
---
Allura/allura/controllers/project.py | 5 +++--
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 | 2 +-
Allura/allura/model/discuss.py | 3 ++-
ForgeTracker/forgetracker/model/ticket.py | 9 +++++----
requirements.in | 2 +-
requirements.txt | 2 +-
9 files changed, 25 insertions(+), 19 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/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 8af7ebef7..830d23709 100644
--- a/Allura/allura/lib/widgets/user_profile.py
+++ b/Allura/allura/lib/widgets/user_profile.py
@@ -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/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.in b/requirements.in
index 177ac4b40..1546be7ad 100644
--- a/requirements.in
+++ b/requirements.in
@@ -13,7 +13,7 @@ feedparser
FormEncode
GitPython
html5lib
-Jinja2==3.1.1
+Jinja2
Markdown
markdown-checklist
MarkupSafe
diff --git a/requirements.txt b/requirements.txt
index d88550a5e..64b267eb9 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -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