Skip to content

Commit

Permalink
fix(prerender): filter encoded links starting with # (#1936)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 20, 2023
1 parent cb7900c commit 088fa34
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/prerender.ts
Expand Up @@ -384,6 +384,7 @@ function extractLinks(
_links.push(
...[...html.matchAll(LINK_REGEX)]
.map((m) => escapeHtml(m[1]))
.filter((m) => !decodeURIComponent(m).startsWith("#"))
.filter((link) => allowedExtensions.has(getExtension(link)))
);
}
Expand Down
2 changes: 2 additions & 0 deletions test/fixture/routes/prerender.ts
Expand Up @@ -39,6 +39,8 @@ ${links.map((link) => ` <li><a href="${link}">${link}</a></li>`).join("\n")}
<link rel="icon" href="data:image/png;base64,aaa//bbbbbb/ccc">
<a x-href="/500?x-href">x-href attr</a>
&lt;a href=&quot;/500&lt;/a&gt;
<a href='#a'>#a</a>
<a href='%23b'>#b</a>
</body>
</html>`;
});

0 comments on commit 088fa34

Please sign in to comment.