Skip to content

Commit

Permalink
Avoid escaping some chars in po files
Browse files Browse the repository at this point in the history
These really do not have to be escaped in the po file, so keep them as
they are.
  • Loading branch information
nijel committed Sep 2, 2017
1 parent 9fa62e7 commit 4f0b897
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion translate/storage/pocommon.py
Expand Up @@ -42,7 +42,7 @@ def extract_msgid_comment(text):

def quote_plus(text):
"""Quote the query fragment of a URL; replacing ' ' with '+'"""
return parse.quote_plus(text.encode("utf-8"))
return parse.quote_plus(text.encode("utf-8"), safe='()/:,')


def unquote_plus(text):
Expand Down
11 changes: 8 additions & 3 deletions translate/storage/test_pocommon.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from translate.storage import pocommon

Expand All @@ -10,6 +11,10 @@ def roundtrip_quote_plus(text, quoted):
assert quote == quoted
unquote = pocommon.unquote_plus(quoted)
assert unquote == text
roundtrip_quote_plus(u"abc", u"abc")
roundtrip_quote_plus(u"key space", u"key+space")
roundtrip_quote_plus(u"key ḓey", u"key+%E1%B8%93ey")
roundtrip_quote_plus("abc", "abc")
roundtrip_quote_plus("key space", "key+space")
roundtrip_quote_plus("key ḓey", "key+%E1%B8%93ey")
roundtrip_quote_plus(
"path/file.c(2):3,path space/file.h:4",
"path/file.c(2):3,path+space/file.h:4"
)

0 comments on commit 4f0b897

Please sign in to comment.