Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Correctly escape special characters in RSS feed URLs #490

Closed
wants to merge 1 commit into from

3 participants

@grischard

As discussed on IRC. Some RSS clients (e.g. NetNewsWire) choke on special characters in URLs.

The problem I'm fixing can be demonstrated by running ` curl http://www.reddit.com/r/stereotest/.rss | grep -o -E http://.+?müllers '. The URLs should contain m%C3%BCllers instead of müllers.

This patch tells quote_plus to urlencode the url strings' special characters to their UTF8 code, unless they are the safe characters ':' or '/'.

@grischard grischard Correctly escape special characters in RSS feed URLs, as discussed on…
… IRC. Some RSS clients choke on special characters in URLs.
846d196
@spladug spladug commented on the diff
r2/r2/templates/link.xml
@@ -32,6 +33,7 @@
url = thing.mousedown_url
else:
url = permalink
+ url = quote_plus(url.encode('utf8'), '/:')
@spladug Owner
spladug added a note

I think this would incorrectly urlencode the domain component of a URL with internationalized domain name, wouldn't it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@spladug
Owner

Side note: we generally try to stick to the convention on how git commit messages should look. Would you mind fixing up your commit message, please?

@grischard

Indeed, I hadn't thought of IDNs at all, so I'll test that, and come back with a properly formatted git commit message. Thank you.

@Deimos
Owner

There haven't been any updates to this pull in a very long time, so I'm going to close it. Please submit a new pull request if you want to reopen it.

@Deimos Deimos closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 12, 2012
  1. @grischard

    Correctly escape special characters in RSS feed URLs, as discussed on…

    grischard authored
    … IRC. Some RSS clients choke on special characters in URLs.
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 0 deletions.
  1. +2 −0  r2/r2/templates/link.xml
View
2  r2/r2/templates/link.xml
@@ -25,6 +25,7 @@
from r2.lib.template_helpers import add_sr, get_domain
from r2.models import FakeSubreddit
from r2.lib.filters import unsafe, safemarkdown
+ from urllib import quote_plus
%>
<%
permalink = add_sr(thing.permalink, force_hostname = True)
@@ -32,6 +33,7 @@
url = thing.mousedown_url
else:
url = permalink
+ url = quote_plus(url.encode('utf8'), '/:')
@spladug Owner
spladug added a note

I think this would incorrectly urlencode the domain component of a URL with internationalized domain name, wouldn't it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
use_thumbs = thing.has_thumbnail and thing.thumbnail and not request.GET.has_key("nothumbs")
%>
<item>
Something went wrong with that request. Please try again.