Permalink
Browse files

Furl 0.3.2 - Removed encoding ambiguity for '+'s in Queries. Spaces e…

…ncode to '+'s. '+'s are URL encoded to '%2B's.
  • Loading branch information...
1 parent 8e86646 commit d9b901fb2bec8c40a05c85440aeda46ad988a144 Arthur Grunseid committed Jul 28, 2012
Showing with 23 additions and 17 deletions.
  1. +1 −1 furl/__init__.py
  2. +2 −4 furl/furl.py
  3. +6 −4 setup.py
  4. +14 −8 tests/test_furl.py
View
@@ -8,7 +8,7 @@
# License: Build Amazing Things (Unlicense)
__title__ = 'furl'
-__version__ = '0.3.1' # Keep synchronized with setup.py.
+__version__ = '0.3.2' # Keep synchronized with ../setup.py.
__author__ = 'Arthur Grunseid'
__contact__ = 'grunseid@gmail.com'
__license__ = 'Unlicense'
View
@@ -301,8 +301,8 @@ class Query(object):
encoded query strings are provided to methods that take such strings, like
load(), add(), set(), remove(), etc.
"""
- SAFE_KEY_CHARS = "/?:@-._~!$'()*+,"
- SAFE_VALUE_CHARS = "/?:@-._~!$'()*+,="
+ SAFE_KEY_CHARS = "/?:@-._~!$'()*,"
+ SAFE_VALUE_CHARS = "/?:@-._~!$'()*,="
def __init__(self, query='', strict=False):
self.strict = strict
@@ -663,8 +663,6 @@ def load(self, url):
tokens = urlsplit(url) # Raises ValueError on malformed IPv6 address.
- print 'tokens', tokens
-
self.netloc = tokens.netloc # Raises ValueError.
self.scheme = tokens.scheme.lower()
if not self.port:
View
@@ -3,15 +3,17 @@
from setuptools import setup, find_packages
if sys.argv[-1] == 'publish':
+ '''
+ Publish Furl to PyPi.
+ '''
os.system('python setup.py sdist upload')
sys.exit()
-long_description = ('''furl: URL parsing and manipulation made simple.
-
-Information and documentation at https://github.com/gruns/furl.''')
+long_description = (
+ 'Information and documentation at https://github.com/gruns/furl.')
setup(name='furl',
- version='0.3.1', # Keep synchronized with __init__.py.
+ version='0.3.2', # Keep synchronized with furl/__init__.py.
author='Arthur Grunseid',
author_email='grunseid@gmail.com',
url='https://github.com/gruns/furl',
View
@@ -537,14 +537,19 @@ def test_params(self):
q = furl.Query('a=a;b=b;c=')
assert q.params == {'a':'a','b':'b','c':''} and str(q) == 'a=a&b=b&c='
- # Non-string parameters are coerved to string in the final query string.
+ # Non-string parameters are coerced to strings in the final query string.
q.params.clear()
q.params[99] = 99
q.params[None] = -1
q.params['int'] = 1
q.params['float'] = 0.39393
- assert 'int=1' in str(q) and 'None=-1' in str(q)
- assert 'float=0.39393' in str(q) and '99=99' in str(q)
+ assert str(q) == '99=99&None=-1&int=1&float=0.39393'
+
+ # Spaces are encoded as '+'s. '+'s are encoded as '%2B'.
+ q.params.clear()
+ q.params['s s'] = 's s'
+ q.params['p+p'] = 'p+p'
+ assert str(q) == 's+s=s+s&p%2Bp=p%2Bp'
# Params is an omdict (ordered multivalue dictionary).
q.params.clear()
@@ -563,12 +568,12 @@ def test_params(self):
def _quote_items(self, items):
# Calculate the expected querystring with proper query encoding.
- # Valid query key characters: "/?:@-._~!$'()*+,;"
- # Valid query value characters: "/?:@-._~!$'()*+,;="
+ # Valid query key characters: "/?:@-._~!$'()*,;"
+ # Valid query value characters: "/?:@-._~!$'()*,;="
allitems_quoted = []
for key, value in items.iterallitems():
- pair = (urllib.quote_plus(str(key), "/?:@-._~!$'()*+,;"),
- urllib.quote_plus(str(value), "/?:@-._~!$'()*+,;="))
+ pair = (urllib.quote_plus(str(key), "/?:@-._~!$'()*,;"),
+ urllib.quote_plus(str(value), "/?:@-._~!$'()*,;="))
allitems_quoted.append(pair)
return allitems_quoted
@@ -1287,7 +1292,8 @@ def test_join(self):
assert f is f.join(join) and f.url == result
def test_urlsplit(self):
- # Without any delimeters like '://' or '/', the input should become a path.
+ # Without any delimeters like '://' or '/', the input should be treated as a
+ # path.
urls = ['sup', '127.0.0.1', 'www.google.com', '192.168.1.1:8000']
for url in urls:
assert isinstance(furl.urlsplit(url), urlparse.SplitResult)

0 comments on commit d9b901f

Please sign in to comment.