This is an automated email from the ASF dual-hosted git repository. gcruz pushed a commit to branch gc/8420 in repository https://gitbox.apache.org/repos/asf/allura.git
commit 3e1be0ae7c1cf9451635e717e606d9928101369c Author: Guillermo Cruz <[email protected]> AuthorDate: Fri Mar 18 11:31:56 2022 -0600 8420 added nofollow to links generated by Markdown syntax and side menu in wiki --- Allura/allura/app.py | 11 +++++++---- Allura/allura/lib/markdown_extensions.py | 2 ++ ForgeWiki/forgewiki/wiki_main.py | 21 ++++++++++++--------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Allura/allura/app.py b/Allura/allura/app.py index e2e34db..6069dfb 100644 --- a/Allura/allura/app.py +++ b/Allura/allura/app.py @@ -664,14 +664,16 @@ class Application: links = [] if self.permissions and has_access(c.project, 'admin')(): links.append( - SitemapEntry('Permissions', admin_url + 'permissions')) + SitemapEntry('Permissions', admin_url + 'permissions', extra_html_attrs={'rel': 'nofollow'})) if force_options or len(self.config_options) > 3: links.append( - SitemapEntry('Options', admin_url + 'options', className='admin_modal')) + SitemapEntry('Options', admin_url + 'options', className='admin_modal', + extra_html_attrs={'rel': 'nofollow'})) links.append( - SitemapEntry('Rename', admin_url + 'edit_label', className='admin_modal')) + SitemapEntry('Rename', admin_url + 'edit_label', className='admin_modal', + extra_html_attrs={'rel': 'nofollow'})) if len(self._webhooks) > 0: - links.append(SitemapEntry('Webhooks', admin_url + 'webhooks')) + links.append(SitemapEntry('Webhooks', admin_url + 'webhooks', extra_html_attrs={'rel': 'nofollow'})) return links @LazyProperty @@ -693,6 +695,7 @@ class Application: label='Delete Everything', url=self.admin_url + 'delete', className='admin_modal', + extra_html_attrs={'rel': 'nofollow'}, ) def handle_message(self, topic, message): diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py index e576db4..b929a6b 100644 --- a/Allura/allura/lib/markdown_extensions.py +++ b/Allura/allura/lib/markdown_extensions.py @@ -488,6 +488,8 @@ class RelativeLinkRewriter(markdown.postprocessors.Postprocessor): # just make sure no spaces val = val.replace(' ', '%20') tag[attr] = val + if 'markdown_syntax' in val: + tag['rel'] = 'nofollow' if '://' in val: if is_nofollow_url(val): tag['rel'] = 'nofollow' diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py index 67e9edc..a7b4a0e 100644 --- a/ForgeWiki/forgewiki/wiki_main.py +++ b/ForgeWiki/forgewiki/wiki_main.py @@ -248,12 +248,13 @@ The wiki uses [Markdown](%s) syntax. if has_create_access: links += [SitemapEntry('Create Page', self.url + 'create_wiki_page/', ui_icon=g.icons['add'], - className='admin_modal')] + className='admin_modal', + extra_html_attrs={'rel': 'nofollow'})] if not admin_menu: links += [SitemapEntry(''), - SitemapEntry('Wiki Home', self.url, className='wiki_home')] - links += [SitemapEntry('Browse Pages', self.url + 'browse_pages/'), - SitemapEntry('Browse Labels', self.url + 'browse_tags/')] + SitemapEntry('Wiki Home', self.url, className='wiki_home', extra_html_attrs={'rel': 'nofollow'})] + links += [SitemapEntry('Browse Pages', self.url + 'browse_pages/', extra_html_attrs={'rel': 'nofollow'}), + SitemapEntry('Browse Labels', self.url + 'browse_tags/', extra_html_attrs={'rel': 'nofollow'})] discussion = self.config.discussion pending_mod_count = M.Post.query.find({ 'discussion_id': discussion._id, @@ -264,7 +265,7 @@ The wiki uses [Markdown](%s) syntax. links.append( SitemapEntry( 'Moderate', discussion.url() + 'moderate', ui_icon=g.icons['moderate'], - small=pending_mod_count)) + small=pending_mod_count, extra_html_attrs={'rel': 'nofollow'})) if not c.user.is_anonymous() and not admin_menu: subscribed = M.Mailbox.subscribed(app_config_id=self.config._id) subscribe_action = 'unsubscribe' if subscribed else 'subscribe' @@ -273,21 +274,23 @@ The wiki uses [Markdown](%s) syntax. '' if subscribed else ' to wiki') subscribe_url = '{}#toggle-{}'.format(self.url + 'subscribe', subscribe_action) links.append(SitemapEntry(None)) - links.append(SitemapEntry(subscribe_title, subscribe_url, ui_icon=g.icons['mail'])) + links.append(SitemapEntry(subscribe_title, subscribe_url, ui_icon=g.icons['mail'], + extra_html_attrs={'rel': 'nofollow'})) if not admin_menu: links += [SitemapEntry(''), - SitemapEntry('Formatting Help', '/nf/markdown_syntax', extra_html_attrs={'target': '_blank'})] + SitemapEntry('Formatting Help', '/nf/markdown_syntax', + extra_html_attrs={'target': '_blank', 'rel': 'nofollow'})] return links def admin_menu(self, skip_common_menu=False): links = [SitemapEntry('Set Home', self.admin_url + 'home', - className='admin_modal')] + className='admin_modal', + extra_html_attrs={'rel': 'nofollow'})] if not self.show_left_bar and not skip_common_menu: links += self.create_common_wiki_menu(has_create_access=True, admin_menu=True) links += super().admin_menu(force_options=True) - return links @h.exceptionless([], log)
