-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Escape <
and >
in info _repr_html_
#7110
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
BUG: Escape <
and >
in info _repr_html_
#7110
Conversation
@@ -485,7 +485,9 @@ def _repr_html_(self): | |||
if self._info_repr(): | |||
buf = StringIO(u("")) | |||
self.info(buf=buf) | |||
return '<pre>' + buf.getvalue() + '</pre>' | |||
# need to escape the <class>, should be the first line. | |||
val = buf.getvalue().replace('<', r'<', 1).replace('>', r'>', 1) |
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.
this going to be very slow I think, maybe do this where the class is actually put their (if you know its html?).
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.
never mind, this is just info repr which is almost always short...
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'm doing a bit of profiling right now. I was hoping that adding the limit of 1
to .replace
would only read the str until it replaces, and I think it might:
In [11]: s = 'abc' + 'S' + ('d' * 1000000)
In [12]: %timeit s.replace('S', 's')
10000 loops, best of 3: 145 µs per loop
In [13]: %timeit s.replace('S', 's', 1)
10000 loops, best of 3: 85.2 µs per loop
I'll have a bit more soon.
rebase on master and you can merge this in when you are ready, I put up the display changes section: 8a8ead6 |
@jreback done. Will just wait on Travis. |
Merged via 2bb2a8d |
Closes #7105
Before: http://nbviewer.ipython.org/gist/TomAugspurger/4c83a646ffb93d5ee978
After: http://nbviewer.ipython.org/gist/TomAugspurger/81bf15086864ca090bb6
After conosle:
FYI, I don't know HTML, but I think this is mostly right.