Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion IPython/lib/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def _repr_html_(self):
else:
params = ""
return self.iframe.format(
src=html_escape(self.src),
src=html_escape(str(self.src)),
width=html_escape(str(self.width)),
height=html_escape(str(self.height)),
params=params,
Expand Down
7 changes: 7 additions & 0 deletions tests/test_display_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import sys
import warnings
from pathlib import Path

from unittest import mock

Expand Down Expand Up @@ -595,6 +596,12 @@ def test_iframe_escaping():
assert 'width="400" onload="alert(1)"' in html._repr_html_()


def test_iframe_path_source():
"""IFrame: pathlib sources are converted to strings before escaping."""
html = display.IFrame(Path("report&notes.html"), 400, 300)._repr_html_()
assert 'src="report&notes.html"' in html


def test_image_bad_filename_raises_proper_exception():
with pytest.raises(FileNotFoundError):
display.Image("/this/file/does/not/exist/")._repr_png_()
Loading