ankurpiyush26 / pubsubhubbub

Automatically exported from code.google.com/p/pubsubhubbub
Other
1 stars 0 forks source link

r204 breaks the encoding of callback URLS containing a port specification #54

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Subscribe to a hub with a callback which specific a port.
2. The callback URL will be badly encoded  
3. Run the verification task.

What is the expected output? What do you see instead?

The subscribtion should be verified, but instead:

verification will fail:

ERROR    2009-08-20 10:20:26,419 main.py:1377] Error encountered while
confirming subscription
Traceback (most recent call last):
  File "/Users/z/devel/pubsubhubbub-read-only/hub/main.py", line 1375, in
confirm_subscription
    follow_redirects=False)
  File "/Users/z/Z
Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-defa
ult.bundle/Contents/Resources/google_appengine/google/appengine/api/urlfetch.py"
,
line 241, in fetch
    return rpc.get_result()
  File "/Users/z/Z
Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-defa
ult.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stu
b_map.py",
line 458, in get_result
    return self.__get_result_hook(self)
  File "/Users/z/Z
Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-defa
ult.bundle/Contents/Resources/google_appengine/google/appengine/api/urlfetch.py"
,
line 325, in _get_fetch_result
    raise DownloadError(str(err))
DownloadError: ApplicationError: 2 (8, 'nodename nor servname provided, or
not known')

What version of the product are you using? On what operating system?
pubsubhubbub-read-only revision 218

Please provide any additional information below.

r204 breaks the encoding of callback URLS containing a port specification:

My callback URL is
http://localhost:8080/feed/7e51ebed097261d30c30ea2f99470a7b626d8dcb/pshb

In hub/main.py:1421, callback = unicode_to_iri(callback) 
encodes the url to:

http://localhost%3A8080/feed/7e51ebed097261d30c30ea2f99470a7b626d8dcb/pshb

in unicode_to_iri:

unicode(url).encode('utf-8').split(':', 1)
['http', '//localhost:8080/feed/7e51ebed097261d30c30ea2f99470a7b626d8dcb/pshb']
then the second part include the colon is encoded:
  return '%s:%s' % (scheme, urllib.quote(rest))

The bug was introduced in r204
(http://groups.google.com/group/pubsubhubbub/browse_thread/thread/3093282998a483
25)

Original issue reported on code.google.com by kugutsu...@gmail.com on 20 Aug 2009 at 10:33

GoogleCodeExporter commented 9 years ago
This fixes the issue. The ':'.join() isnt as clean as string.join, but I 
figured it
would be better to not add an import.

===================================================================
--- main.py (revision 219)
+++ main.py (working copy)
@@ -253,8 +253,8 @@
   Returns:
     A properly encoded IRI (see RFC 3987).
   """
-  scheme, rest = unicode(url).encode('utf-8').split(':', 1)
-  return '%s:%s' % (scheme, urllib.quote(rest))
+  parts = unicode(url).encode('utf-8').split(':')
+  return ':'.join(map(urllib.quote, parts))

Original comment by alex.schoof on 21 Aug 2009 at 1:44

GoogleCodeExporter commented 9 years ago

Original comment by bslatkin on 25 Aug 2009 at 2:59