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

display() tries to read files and load URLs #12195

Open
Tronic opened this issue Mar 19, 2020 · 2 comments
Open

display() tries to read files and load URLs #12195

Tronic opened this issue Mar 19, 2020 · 2 comments

Comments

@Tronic
Copy link

Tronic commented Mar 19, 2020

Quite surprisingly, instead of a HTML string snippet, IPython actually loads a local file or a remote site if anything suitable is found.

from IPython.core.display import display, HTML

# This does what I would expect
display(HTML("<h1>Hello</h1>"))

# These are quite scary
display(HTML("/etc/passwd"))
display(HTML("https://google.com/"))

I found out about this feature when I tried to print text foo and the system hung because I happened to have a special file by that name in the current folder. The relevant code is in IPython/core/display.py:608.

It would be far more secure if there were separate types or kwargs for displaying files and URLs.

@Carreau
Copy link
Member

Carreau commented Mar 19, 2020

This has been unfortunately baked in fo several years, and as you point out from the source they are differents args/kwarrgs, you can do display(HTML(url="https://google.com/")) and it will force it to be intepreted a URL.

Do you have a more concrete proposal ?

@Tronic
Copy link
Author

Tronic commented Mar 19, 2020

I suppose it isn't possible to specify data by kwarg so that it won't be interpreted as something else? In any case, it might be better to deprecate and eventually move on rather than keep it forever.

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

2 participants