FIX: URL encode usernames in user profile links in RSS feeds

user_url() failed for usernames containing Unicode characters because it expects URL encoded usernames. RSS feeds do not support IRIs, so lets convert them to URIs by encoding the usernames.
This commit is contained in:
Gerhard Schlager 2019-07-18 23:17:29 +02:00
parent 533f5172d7
commit 2ecc613c5d
2 changed files with 2 additions and 2 deletions

View File

@ -20,7 +20,7 @@
<category><%= topic.category.name %></category>
<description><![CDATA[
<% if username.present? %>
<p><%= t('author_wrote', author: link_to("@#{username}", "#{Discourse.base_url}/u/#{topic.user.username_lower}")).html_safe %></p>
<p><%= t('author_wrote', author: link_to("@#{username}", "#{Discourse.base_url}/u/#{url_encode(topic.user.username_lower)}")).html_safe %></p>
<% end %>
<blockquote>
<%- if first_post = topic.ordered_posts.first %>

View File

@ -18,7 +18,7 @@
<dc:creator><![CDATA[<%= "@#{post.user.username}#{" #{post.user.name}" if (post.user.name.present? && SiteSetting.enable_names?)}" -%>]]></dc:creator>
<description><![CDATA[
<% post_url = Discourse.base_url + post.url %>
<p><%= t('author_wrote', author: link_to("@#{post.user.username}", user_url(post.user.username_lower))).html_safe %></p>
<p><%= t('author_wrote', author: link_to("@#{post.user.username}", "#{Discourse.base_url}/u/#{url_encode(post.user.username_lower)}")).html_safe %></p>
<blockquote>
<% if post.hidden %>
<%= t('flagging.user_must_edit').html_safe %>