diff --git a/nbconvert/exporters/tests/files/notebook_inject.ipynb b/nbconvert/exporters/tests/files/notebook_inject.ipynb
index 2c745d666..8f3c8dd53 100644
--- a/nbconvert/exporters/tests/files/notebook_inject.ipynb
+++ b/nbconvert/exporters/tests/files/notebook_inject.ipynb
@@ -102,6 +102,40 @@
}
],
"source": [""]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "b72e635a",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "image/png": ["\">"]
+ },
+ "execution_count": null,
+ "metadata": {}
+ }
+ ],
+ "source": [""]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "p72e635a",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "image/jpeg": ["\">"]
+ },
+ "execution_count": null,
+ "metadata": {}
+ }
+ ],
+ "source": [""]
}
],
"metadata": {
diff --git a/nbconvert/exporters/tests/test_html.py b/nbconvert/exporters/tests/test_html.py
index b17e63a3c..d870ea302 100644
--- a/nbconvert/exporters/tests/test_html.py
+++ b/nbconvert/exporters/tests/test_html.py
@@ -159,3 +159,7 @@ def test_javascript_injection(self):
# Check injection in image filenames
assert "" not in output
assert "" not in output
+
+ # Check injection in image data
+ assert "" not in output
+ assert "" not in output
diff --git a/share/jupyter/nbconvert/templates/classic/base.html.j2 b/share/jupyter/nbconvert/templates/classic/base.html.j2
index bdc89bebc..70f87f274 100644
--- a/share/jupyter/nbconvert/templates/classic/base.html.j2
+++ b/share/jupyter/nbconvert/templates/classic/base.html.j2
@@ -158,7 +158,7 @@ unknown type {{ cell.type }}
{%- if 'image/png' in output.metadata.get('filenames', {}) %}