修正 fetchScriptBody 的 Accept 设定,避免触发 Error 406#1306
Open
cyfung1031 wants to merge 1 commit intoscriptscat:mainfrom
Open
修正 fetchScriptBody 的 Accept 设定,避免触发 Error 406#1306cyfung1031 wants to merge 1 commit intoscriptscat:mainfrom
cyfung1031 wants to merge 1 commit intoscriptscat:mainfrom
Conversation
Closed
CodFrm
reviewed
Mar 22, 2026
| "Cache-Control": "no-cache", | ||
| Accept: "text/javascript,application/javascript,text/plain,application/octet-stream,application/force-download", | ||
| /* 不指定 application/octet-stream 和 application/force-download 避免触发伺服器端 Error 406 */ | ||
| Accept: "text/javascript, application/javascript, */*", // prefer JavaScript, but anything is acceptable |
Collaborator
Author
There was a problem hiding this comment.
这个还好吧。之前没 */*
加了 */* 后就不会让 Server报错
只是 javascript 优先
| const contentType = response.headers.get("content-type"); | ||
|
|
||
| if (contentType) { | ||
| // 不接受非 JavaScript文本 的回应 |
Collaborator
Author
There was a problem hiding this comment.
避免恶意连结。如果类型不对,就不下载了
Collaborator
Author
There was a problem hiding this comment.
这个包括网址不正确的跳页。会直接不下载而不是下载后再解析
Collaborator
Author
|
@CodFrm 你再看看吧。我认为这些测试都是必须的。因为不知道用户会点了什么连结 |
Member
去了吧,我们也不清楚服务端会不会按照所规定的来执行,也会导致错误;反正最后会实际的解析脚本代码,来确定脚本是否正确 |
Collaborator
Author
之前 Accept 没加 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist / 检查清单
Description / 描述
修正 fetchScriptBody 的 Accept 设定,避免触发 Error 406
(see #1271)
测试: https://openuserjs.org/scripts/alexchen/eHunter
Screenshots / 截图