Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Urls surrounded by parenthesis with a path are being parsed incorrectly. #10

Open
lextoumbourou opened this issue May 6, 2015 · 3 comments

Comments

@lextoumbourou
Copy link

Hi @edburnett,

This works (and you've got a test for it ❤️):

In [1]: from ttp import ttp
In [2]: p = ttp.Parser()
In [3]: res = p.parse("test (http://example.com)")
In [4]: res.urls
Out[4]: ['http://example.com']
In [5]: res.html
Out[5]: u'test (<a href="http://example.com">http://example.com</a>)'

However, this does not:

In [6]: res = p.parse("test (http://example.com/directory)")
In [7]: res.urls
Out[7]: ['http://example.com/directory)']
In [8]: res.html
Out[8]: u'test (<a href="http://example.com/directory)">http://example.com/directory)</a>'

Note the right parentheses being treated as part of the URL?

Thanks,

Lex

@lextoumbourou lextoumbourou changed the title Urls surrounded by parenthesis with a path are being parsed correctly. Urls surrounded by parenthesis with a path are being parsed incorrectly. May 6, 2015
@docapotamus
Copy link

This isn't necersarily a bug as ) is valid character in a URL path

@edmondburnett
Copy link
Owner

Since parentheses are valid within URLs, perhaps we could say that if there is an opening parentheses before the protocol, i.e. (http:// AND a closing paren at the end of the URL, then only in that case we can ignore/strip them. Because then we could probably assume the user intended to enclose the URL inside parens.

@docapotamus
Copy link

@edmondburnett I think that sounds like a sensible solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants