This is an automated email from the ASF dual-hosted git repository. brondsem pushed a commit to branch db/8536 in repository https://gitbox.apache.org/repos/asf/allura.git
commit 8f1efe7987fb0d889336c2e4080d8f488376e5a3 Author: Dave Brondsema <dbronds...@slashdotmedia.com> AuthorDate: Fri Feb 9 16:13:42 2024 -0500 [#8536] remove unnecessary |safe usages --- Allura/allura/controllers/search.py | 2 +- Allura/allura/lib/app_globals.py | 4 ++-- Allura/allura/templates/oauth_applications.html | 4 ++-- Allura/allura/templates/oauth_authorize.html | 2 +- Allura/allura/templates/project_list.html | 4 ---- Allura/allura/templates/repo/merge_request.html | 2 +- Allura/allura/templates/widgets/include.html | 2 +- Allura/allura/templates/widgets/post_widget.html | 4 ++-- .../templates/blog_widgets/preview_post.html | 2 +- .../forgeblog/templates/blog_widgets/view_post.html | 2 +- ForgeChat/forgechat/templates/chat/day.html | 2 +- .../templates/discussion_widgets/forum_header.html | 2 +- .../templates/discussionforums/admin_forums.html | 2 +- .../forgetracker/templates/tracker/ticket.html | 2 +- .../templates/tracker_widgets/ticket_form.html | 20 ++++++++++---------- ForgeWiki/forgewiki/templates/wiki/browse.html | 2 +- 16 files changed, 27 insertions(+), 31 deletions(-) diff --git a/Allura/allura/controllers/search.py b/Allura/allura/controllers/search.py index f0db69f73..31c5f1e48 100644 --- a/Allura/allura/controllers/search.py +++ b/Allura/allura/controllers/search.py @@ -130,4 +130,4 @@ class ProjectBrowseController(BaseController): projects, count = self._find_projects() title = self._build_title() c.custom_sidebar_menu = self._build_nav() - return dict(projects=projects, title=title, text=None) + return dict(projects=projects, title=title) diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py index 9cc3d86bb..0bdf8be08 100644 --- a/Allura/allura/lib/app_globals.py +++ b/Allura/allura/lib/app_globals.py @@ -94,7 +94,7 @@ class ForgeMarkdown: 'markdown_checklist.extension'], output_format='html') - def convert(self, source, render_limit=True): + def convert(self, source, render_limit=True) -> Markup: if render_limit and len(source) > asint(config.get('markdown_render_max_length', 80000)): # if text is too big, markdown can take a long time to process it, # so we return it as a plain text @@ -113,7 +113,7 @@ class ForgeMarkdown: regex_names = '|'.join(uncacheable_macros_names()) return re.compile(rf"\[\[\s*({regex_names})\b") - def cached_convert(self, artifact: MappedClass, field_name: str) -> str: + def cached_convert(self, artifact: MappedClass, field_name: str) -> Markup: """ Convert ``artifact.field_name`` markdown source to html, caching the result if the render time is greater than the defined threshold. diff --git a/Allura/allura/templates/oauth_applications.html b/Allura/allura/templates/oauth_applications.html index 9114f3d3e..c788e7722 100644 --- a/Allura/allura/templates/oauth_applications.html +++ b/Allura/allura/templates/oauth_applications.html @@ -83,7 +83,7 @@ <th>Name:</th><td>{{access_token.consumer_token.name}}</td> </tr> <tr class="description"> - <th>Description:</th><td>{{access_token.consumer_token.description_html | safe}}</td> + <th>Description:</th><td>{{access_token.consumer_token.description_html }}</td> </tr> {% if access_token.is_bearer %} <tr class="bearer_token"> @@ -117,7 +117,7 @@ {% for consumer_token in consumer_tokens %} <table class="registered_app"> <tr><th>Name:</th><td>{{consumer_token.name}}</td></tr> - <tr class="description"><th>Description:</th><td>{{consumer_token.description_html | safe}}</td></tr> + <tr class="description"><th>Description:</th><td>{{consumer_token.description_html }}</td></tr> <tr class="consumer_key"><th>Consumer Key:</th><td>{{consumer_token.api_key}}</td></tr> <tr class="consumer_secret"><th>Consumer Secret:</th><td>{{consumer_token.secret_key}}</td></tr> <tr class="controls"> diff --git a/Allura/allura/templates/oauth_authorize.html b/Allura/allura/templates/oauth_authorize.html index cd8f9655e..d3afc8b3d 100644 --- a/Allura/allura/templates/oauth_authorize.html +++ b/Allura/allura/templates/oauth_authorize.html @@ -51,7 +51,7 @@ <br style="clear:both"/> <div class="flex-container"> <p><strong>App Name:</strong> {{consumer.name}}</p> - <p><strong>Description:</strong> <br> {{consumer.description_html|safe}}</p> + <p><strong>Description:</strong> <br> {{consumer.description_html}}</p> </div> <br style="clear:both"/> <div class="flex-container"> diff --git a/Allura/allura/templates/project_list.html b/Allura/allura/templates/project_list.html index 6232a2411..9d68850ae 100644 --- a/Allura/allura/templates/project_list.html +++ b/Allura/allura/templates/project_list.html @@ -51,10 +51,6 @@ {% block content %} {% set old_project = c.project %} - {% if text %} - {{text|safe}} - {% endif %} - {% if not projects %} <p>No projects found</p> {% else %} diff --git a/Allura/allura/templates/repo/merge_request.html b/Allura/allura/templates/repo/merge_request.html index 59168eefd..6f562b8b4 100644 --- a/Allura/allura/templates/repo/merge_request.html +++ b/Allura/allura/templates/repo/merge_request.html @@ -135,7 +135,7 @@ Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}}) To merge the commits, please execute the following commands in your working copy: </div> <div class="grid-19"> - <textarea class="merge-instructions" readonly>{{ c.app.repo.merge_command(req) | safe }}</textarea> + <textarea class="merge-instructions" readonly>{{ c.app.repo.merge_command(req) }}</textarea> </div> {% if merge_status not in ('ready', 'busy') %} {{ c.mr_dispose_form.display(action="save", value=dict(status=req.status)) }} diff --git a/Allura/allura/templates/widgets/include.html b/Allura/allura/templates/widgets/include.html index db9fcaf64..a28ac88ca 100644 --- a/Allura/allura/templates/widgets/include.html +++ b/Allura/allura/templates/widgets/include.html @@ -18,7 +18,7 @@ -#} <div{{attrs|default({}, true)|xmlattr}}> {% if artifact %} - {{artifact.html_text|safe}} + {{artifact.html_text}} {% else %} {{text}} {% endif %} diff --git a/Allura/allura/templates/widgets/post_widget.html b/Allura/allura/templates/widgets/post_widget.html index ef205bcba..a234a8bc2 100644 --- a/Allura/allura/templates/widgets/post_widget.html +++ b/Allura/allura/templates/widgets/post_widget.html @@ -94,7 +94,7 @@ <b>{{value.subject or '(no subject)'}}<br/></b> {% endif %} - <div{% if can_moderate_post %} class="active-md" data-markdownlink="{{value.url()}}" {% endif %}>{{g.markdown.cached_convert(value, 'text')|safe}}</div> + <div{% if can_moderate_post %} class="active-md" data-markdownlink="{{value.url()}}" {% endif %}>{{g.markdown.cached_convert(value, 'text')}}</div> <div class='reactions{% if not c.user.is_anonymous() %} reactions-active{% endif %}' style='user-select: none; cursor: default'> {% for reaction in value.react_counts %}<div class="reaction{% if current_reaction == reaction %} reaction-current{% endif %}" data-react="{{ reaction }}"><div class="emoj">{{ h.emojize(reaction) }}</div><div class="emoj-count">{{ value.react_counts[reaction] }}</div></div>{% endfor %} </div> @@ -194,4 +194,4 @@ $('.attachment_toolbar #remove-attachment').on('click', function(e){ $(this).closest('form').submit(); }) </script> -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/ForgeBlog/forgeblog/templates/blog_widgets/preview_post.html b/ForgeBlog/forgeblog/templates/blog_widgets/preview_post.html index 81e1d850d..6e0ed4f1a 100644 --- a/ForgeBlog/forgeblog/templates/blog_widgets/preview_post.html +++ b/ForgeBlog/forgeblog/templates/blog_widgets/preview_post.html @@ -21,7 +21,7 @@ <h3> <a href="{{value.url()}}">{{value.title}}</a> </h3> - {{value.html_text_preview|safe}} + {{value.html_text_preview}} <em class="grid-19"> Posted by {{lib.user_link(value.author(), avatar=True)}} {{lib.abbr_date(value.timestamp)}} {% if value.state != 'published' %} diff --git a/ForgeBlog/forgeblog/templates/blog_widgets/view_post.html b/ForgeBlog/forgeblog/templates/blog_widgets/view_post.html index 16e281bfb..7dbdfeae2 100644 --- a/ForgeBlog/forgeblog/templates/blog_widgets/view_post.html +++ b/ForgeBlog/forgeblog/templates/blog_widgets/view_post.html @@ -18,7 +18,7 @@ -#} {% import 'allura:templates/jinja_master/lib.html' as lib with context %} -<div{% if h.has_access(value, 'edit') %} class="active-md" data-markdownlink="" {% endif %}>{{value.html_text|safe}}</div> +<div{% if h.has_access(value, 'edit') %} class="active-md" data-markdownlink="" {% endif %}>{{value.html_text}}</div> {{lib.related_artifacts(value, c.user)}} <em class="grid-19"> Posted by {{lib.user_link(base_post.author(), avatar=True)}} {{lib.abbr_date(value.timestamp)}} diff --git a/ForgeChat/forgechat/templates/chat/day.html b/ForgeChat/forgechat/templates/chat/day.html index 26ddcacc7..81d396b4a 100644 --- a/ForgeChat/forgechat/templates/chat/day.html +++ b/ForgeChat/forgechat/templates/chat/day.html @@ -44,7 +44,7 @@ {{msg.sender_short}} </div> </div> - <div style='margin-left:13em'>{{g.markdown.cached_convert(msg, 'text') | safe}}</div> + <div style='margin-left:13em'>{{g.markdown.cached_convert(msg, 'text')}}</div> </div> <div style='clear:both'></div> </li> diff --git a/ForgeDiscussion/forgediscussion/templates/discussion_widgets/forum_header.html b/ForgeDiscussion/forgediscussion/templates/discussion_widgets/forum_header.html index 18b6e483e..c06a94112 100644 --- a/ForgeDiscussion/forgediscussion/templates/discussion_widgets/forum_header.html +++ b/ForgeDiscussion/forgediscussion/templates/discussion_widgets/forum_header.html @@ -18,7 +18,7 @@ -#} {% import 'allura:templates/jinja_master/lib.html' as lib with context %} -{{g.markdown.cached_convert(value, 'description')|safe}} +{{g.markdown.cached_convert(value, 'description')}} {% if value.announcements %} <h3>Announcements</h3> diff --git a/ForgeDiscussion/forgediscussion/templates/discussionforums/admin_forums.html b/ForgeDiscussion/forgediscussion/templates/discussionforums/admin_forums.html index ddfad95c5..9048bdb18 100644 --- a/ForgeDiscussion/forgediscussion/templates/discussionforums/admin_forums.html +++ b/ForgeDiscussion/forgediscussion/templates/discussionforums/admin_forums.html @@ -69,7 +69,7 @@ </span> </div> <div class="editable viewing"> - <div class="viewer">{{g.markdown.cached_convert(forum, 'description')|safe}}</div> + <div class="viewer">{{g.markdown.cached_convert(forum, 'description')}}</div> <span class="editor multiline"> {{lib.text_area('forum-%s.description' % loop.index0, 'Description', h.really_unicode(forum.description))}} </span> diff --git a/ForgeTracker/forgetracker/templates/tracker/ticket.html b/ForgeTracker/forgetracker/templates/tracker/ticket.html index e17020bf7..8af471d70 100644 --- a/ForgeTracker/forgetracker/templates/tracker/ticket.html +++ b/ForgeTracker/forgetracker/templates/tracker/ticket.html @@ -151,7 +151,7 @@ {{ c.vote_form.display(artifact=ticket) }} {% endif %} <div id="ticket_content"> - <div{% if h.has_access(ticket, 'update') %} class="active-md" data-markdownlink=""{% endif %}>{{g.markdown.cached_convert(ticket, 'description')|safe}}</div> + <div{% if h.has_access(ticket, 'update') %} class="active-md" data-markdownlink=""{% endif %}>{{g.markdown.cached_convert(ticket, 'description')}}</div> {% if ticket.attachments %} <strong class="grid-18">{{ticket.attachments|length}} Attachments</strong> <div class="clear"> diff --git a/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html b/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html index 3afc9eb49..39d514503 100644 --- a/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html +++ b/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html @@ -18,28 +18,28 @@ -#} {% import 'allura:templates/jinja_master/lib.html' as lib with context %} <form method="POST" action="{{action}}" enctype="multipart/form-data" id="ticket-form"> - {{widget.display_field_by_name('ticket_num')|safe}} + {{widget.display_field_by_name('ticket_num')}} {% if help_msg %} <div id="new-ticket-help-msg" class="grid-19 info">{{g.markdown.convert(help_msg)}}</div> {% endif %} <div class="grid-18"> <div class="new-ticket-title"> - <label>Create Ticket:</label>{{widget.display_field_by_name('summary')|safe}} + <label>Create Ticket:</label>{{widget.display_field_by_name('summary')}} </div> </div> {% if widget.fields['_milestone'] %} <div class="grid-6"> <label class="cr">Milestone:</label> - {{widget.display_field_by_name('_milestone')|safe}} + {{widget.display_field_by_name('_milestone')}} </div> {% endif %} <div class="grid-6"> <label class="cr">Status:</label> - {{widget.display_field_by_name('status')|safe}} + {{widget.display_field_by_name('status')}} </div> <div class="grid-6"> <label class="cr">Owner:</label> - {{widget.display_field_by_name('assigned_to')|safe}} + {{widget.display_field_by_name('assigned_to')}} </div> <div style="clear:both"> </div> {% set min_c_fields = widget.fields['_milestone'] and 1 or 0 %} @@ -49,7 +49,7 @@ {% endif %} <div class="grid-12"> <label class="cr">Labels:</label> - {{widget.display_field_by_name('labels')|safe}} + {{widget.display_field_by_name('labels')}} </div> <div class="grid-6"> {{widget.display_field_by_name('private')}} @@ -86,7 +86,7 @@ </div> <div style="clear:both"> </div> <div class="grid-18"> - {{widget.display_field_by_name('description')|safe}} + {{widget.display_field_by_name('description')}} </div> <div style="clear:both"> </div> <div class="grid-18"> @@ -106,7 +106,7 @@ {% endfor %} </div> {% endif %} - {{widget.display_field_by_name('attachment')|safe}} + {{widget.display_field_by_name('attachment')}} </div> <div style="clear:both"> </div> <div class="reply" style="position:relative;{% if not show_comment %} display:none{% endif %}"> @@ -119,13 +119,13 @@ </p> </div> <div class="grid-16"> - {{widget.display_field_by_name('comment')|safe}} + {{widget.display_field_by_name('comment')}} <span class="arw"><span></span></span> </div> </div> <div style="clear:both"> </div> <div class="grid-18"> - {{widget.display_field_by_name('submit')|safe}} + {{widget.display_field_by_name('submit')}} {% if c.user and c.user != c.user.anonymous() and not ticket and not subscribed_to_tool|default %} <label class="subscribe"> <input type="checkbox" checked name="ticket_form.subscribe" class="subscribe-checkbox">Subscribe to this ticket diff --git a/ForgeWiki/forgewiki/templates/wiki/browse.html b/ForgeWiki/forgewiki/templates/wiki/browse.html index 3a96aa719..c384f0f1c 100644 --- a/ForgeWiki/forgewiki/templates/wiki/browse.html +++ b/ForgeWiki/forgewiki/templates/wiki/browse.html @@ -45,7 +45,7 @@ <tbody> {% for page in pages %} <tr class="{{'deleted ' if page.deleted else ''}}{{loop.cycle('', 'even')}}"> - <td><a href="{{page.url|safe}}">{{page['title']}}</a></td> + <td><a href="{{page.url}}">{{page['title']}}</a></td> {% if 'user_name' in page %} <td><a href="{{ h.username_project_url(page['user_name']) }}" class="user-mention">{{ page['user_name'] }}</a></td>