diff --git a/r2/example.ini b/r2/example.ini old mode 100644 new mode 100755 index 593335219e..e999790ab9 --- a/r2/example.ini +++ b/r2/example.ini @@ -375,6 +375,9 @@ share_reply = noreply@reddit.com # feedback email feedback_email = reddit@gmail.com +# Special case sensitive domains +case_sensitive_domains = i.imgur.com, youtube.com + [server:main] use = egg:Paste#http host = 0.0.0.0 diff --git a/r2/r2/lib/app_globals.py b/r2/r2/lib/app_globals.py old mode 100644 new mode 100755 index ac3a710b72..ac4b5ccf6a --- a/r2/r2/lib/app_globals.py +++ b/r2/r2/lib/app_globals.py @@ -110,7 +110,8 @@ class Globals(object): 'authorized_cnames', 'hardcache_categories', 'proxy_addr', - 'allowed_pay_countries'] + 'allowed_pay_countries', + 'case_sensitive_domains'] choice_props = {'cassandra_rcl': {'ONE': CL_ONE, 'QUORUM': CL_QUORUM}, diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py old mode 100644 new mode 100755 index 69e70958a8..cc7e45348e --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -538,7 +538,13 @@ class LinksByUrl(tdb_cassandra.View): @classmethod def _key_from_url(cls, url): - keyurl = _force_utf8(UrlParser.base_url(url.lower())) + if not utils.domain(url) in g.case_sensitive_domains: + keyurl = _force_utf8(UrlParser.base_url(url.lower())) + else: + # Convert only hostname to lowercase + up = UrlParser(url) + up.hostname = up.hostname.lower() + keyurl = _force_utf8(UrlParser.base_url(up.unparse())) return keyurl # Note that there are no instances of PromotedLink or LinkCompressed,