-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add PDF URL validation and content type check #1896
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
feat: add PDF URL validation and content type check #1896
Conversation
Signed-off-by: Yukai Huang <yukaihuangtw@gmail.com>
695f27e to
55e9de3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds PDF URL validation and a content type check to improve the reliability of PDF embedding.
- Added an async function isPdfUrl in utils.js to check if a URL returns a PDF Content-Type.
- Updated extra.js to perform both extension and content type checks before embedding a PDF.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| public/js/utils.js | Added isPdfUrl to fetch HEAD and validate the Content-Type header |
| public/js/extra.js | Integrated PDF validation logic with both extension and content type checks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Uh oh!
There was an error while loading. Please reload this page.
Companion test script
A bun proxy server that serve xss content
https://william957-web.github.io/meow_xss.htmlAnd reverse proxy
And embed with:
{%pdf https://local.localhost/proxy-as-pdf.pdf %}