#18152: urlize filter does not work correctly in combination with linebreaksbr
filter
-------------------------------------+-------------------------------------
Reporter: Nasmon | Owner:
Type: Bug | Vladimir.Filonov
Component: Template system | Status: assigned
Severity: Normal | Version: 1.4
Keywords: | Resolution:
Has patch: 0 | Triage Stage: Accepted
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Vladimir.Filonov):
This problem because `urlize` using words splitting to search links. For
splitting it uses `re.compile(r'(\s+)')` - all common space symbols.
So, when first filter is `linebreaks` and second is urlize we have such
steps:
# String is "Lorem ipsum\nhttp://some.com/web-page\nLorem ipsum"
1. String is converted to "Lorem ipsum<br /> http://some.com/web-page<br
/>Lorem ipsum"
2. String is splitted to chucks ['Lorem ipsum<br', '/>http://some.com/web-
page<br', '/>Lorem ipsum']
3. Nothing to urlize, because '/>http://some.com/web-page<br' doesn't
looks like a link.
# String is "Lorem ipsum\n http://some.com/web-page\nLorem ipsum"
1. String is converted to "Lorem ipsum<br /> http://some.com/web-page<br
/>Lorem ipsum"
2. String is splitted to chucks ['Lorem ipsum<br', '/>', 'http://some.com
/web-page<br', '/>Lorem ipsum']
3. Link is 'http://some.com/web-page<br'
# String is "Lorem ipsum\n http://some.com/web-page \nLorem ipsum"\
1. String is converted to "Lorem ipsum<br /> http://some.com/web-page<br
/>Lorem ipsum"
2. String is splitted to chucks ['Lorem ipsum<br', '/>', 'http://some.com
/web-page', '<br', '/>Lorem ipsum']
3. Link is 'http://some.com/web-page'
So, spaces should be at both sides of URL for normal work.
I see two ways, but both of them are not clear for my opinion.
First is to add spaces around <br /> tags in `linebreaksbr` filter. But it
will change a lot of output.
Second way is to change Regular Extension for splitting url. In fact we
can split string using not only spaces, but all non-url symbols, according
RCF1738.
Any ideas?
--
Ticket URL: <https://code.djangoproject.com/ticket/18152#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.