Skip to content

Commit

Permalink
Don't choke on iframes without a src (#3272)
Browse files Browse the repository at this point in the history
Fixes #3271
  • Loading branch information
peterbe authored Mar 17, 2021
1 parent d75d607 commit aaec11e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion build/flaws.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function injectFlaws(doc, $, options, document) {
}
}

function injectUnsafeHTMLFlaws(doc, $, { rawContent }) {
function injectUnsafeHTMLFlaws(doc, $, { rawContent, fileInfo }) {
function addFlaw(element, explanation) {
if (!("unsafe_html" in doc.flaws)) {
doc.flaws.unsafe_html = [];
Expand Down Expand Up @@ -131,6 +131,12 @@ function injectUnsafeHTMLFlaws(doc, $, { rawContent }) {
if (tagName === "iframe") {
// For iframes we only check the 'src' value
const src = $(element).attr("src");
if (!src) {
console.warn(
`${fileInfo.path} has an iframe without a 'src' attribute`
);
return;
}
// Local URLs are always safe.
if (!(src.startsWith("//") || src.includes("://"))) {
return;
Expand Down

0 comments on commit aaec11e

Please sign in to comment.