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
rose bush: view: default to escaping output HTML #1809
rose bush: view: default to escaping output HTML #1809
Conversation
…links when in text mode
# convert url(s) to hyperlinks if in text mode | ||
if mode == None: | ||
anchor = lambda url: '<a href="%s">%s</a>' % (url, url) | ||
urlregex = '(http|https|ftp)://[^\s]+' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URL detection quite crude, expects urls to be space or new line terminated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be worth doing:
\b(?:https?|ftp)://\S+\b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to use re.compile
to pre-compile the regular expression to speed things up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that regex is far better.
lines[i] = '%s'*3 % ( | ||
line[:begining], | ||
'<a href="{0}">{0}</a>'.format(match.group(0)), | ||
line[end:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the intention of this change, but I think this is leaking template logic into this module. Jinja2 appears to have a urlize
filter that should allow us to do this sort of stuff within the template.
@benfitzpatrick please sanity check. |
Great |
rose bush: view: default to escaping output HTML
Also added feature to make url(s) clickable when in text mode.
closes #1684
@matthewrmshin Please review
@benfitzpatrick Please review