Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix: Sanitize YouTube No-Cookie URL by Validating Hostname#1716

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
apodacaduron wants to merge1 commit intosachinchoolur:master
base:master
Choose a base branch
Loading
fromapodacaduron:fix/youtube-nocookie-host-check

Conversation

@apodacaduron
Copy link

Problem

The current implementation ofisYouTubeNoCookie(url) uses a substring check:

returnurl.includes('youtube-nocookie.com');

This is unsafe becauseyoutube-nocookie.com can appear anywhere in the string, including in malicious or misleading URLs such as:https://attacker.com/youtube-nocookie.com.fake.site
This would incorrectly pass the check, even though the host is notyoutube-nocookie.com.

Solution

This PR improves the validation by parsing the URL with the URL constructor and comparing the host value directly:

varisYouTubeNoCookie=function(url){try{varparsedUrl=newURL(url);returnparsedUrl.host==='youtube-nocookie.com';}catch(e){returnfalse;// Fails safely if the URL is invalid}};

This ensures the function only returns true for valid URLs that have an exact hostname match.

Benefits

✅ Prevents false positives on malicious or incorrectly formatted URLs
✅ Improves security by relying on structured URL parsing
✅ Passes CodeQL analysis and aligns with secure coding practices
✅ Makes the plugin more robust and reliable

Replaces substring check in `isYouTubeNoCookie()` with explicit hostname validationusing the URL constructor. This prevents potential false positives or security risksfrom malformed or malicious URLs.Fix suggested by static analysis (CodeQL) and aligns with best practices forURL sanitization.
@CLAassistant
Copy link

CLAassistant commentedJun 4, 2025
edited
Loading

CLA assistant check
All committers have signed the CLA.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@apodacaduron@CLAassistant

[8]ページ先頭

©2009-2025 Movatter.jp