Michael Diamond [email protected] www.DigitalGemstones.com
On Tue, Aug 7, 2012 at 9:19 AM, Zhang Huangbin <[email protected]>wrote: > With last commit, we have function web.database.dburl2dict. but it doesn't > work if password contains '@'. > > >>> dburl2dict('postgres://james:"pw_with_@"@ > serverfarm.example.net:5432/mygreatdb') > {'host': '"@serverfarm.example.net', 'pw': '"pw_with_', ...} > > As you can see, both host and pw are incorrect. > You can't have an unescaped '@' character in a URL for this very reason - the character has a special meaning, and leaving it clear makes parsing the URL ambiguous: http://en.wikipedia.org/wiki/Uniform_resource_locator#List_of_allowed_URL_characters Java's URL class makes the same parsing decision (URL doesn't accept postgres so I switched it to http): URL u = new URL("http://james:\"pw_with_@\"@ serverfarm.example.net:5432/mygreatdb"); System.out.println(u.getHost()); # "@serverfarm.example.net System.out.println(u.getUserInfo()); # james:"pw_with_ The correct solution is to escape your password before passing it to dburl2dict, probably using http://docs.python.org/library/urllib#urllib.quote_plus (may want to pass '' as the second argument, to also escape '/' characters), since there's no way for dburl2dict to know how to "properly" parse your malformed URL. Michael -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
