Skip to content

fix(handles): fix that when downloading, markdown file will be parsed into html. #8540

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

stephen-zeng
Copy link

@stephen-zeng stephen-zeng commented May 18, 2025

修复了在代理模式下(比如本地),markdown文档在下载的情况下依然会被自动parse成html的问题,这会导致下载的markdown文件都是parse过的,如截图所示。
Fixed the problem that in proxy mode (such as local),markdown documents will still be automatically parsed into html when downloaded, which will cause the downloaded markdown files to be parsed, as shown in the screenshot.

image
image

如果是其他类型的文件(如txt)就没有这个问题。
If it is other types of files (such as txt), there is no problem.

image
image

Copy link

Walkthrough

This pull request addresses an issue where markdown files were automatically parsed into HTML in proxy mode, affecting their preview and download. The fix involves removing the code that prioritized markdown file processing, ensuring that markdown files are no longer converted to HTML.

Changes

File Summary
server/handles/down.go Removed the code that prioritized markdown file processing, which caused them to be parsed into HTML.

@stephen-zeng stephen-zeng changed the title fix(handles): fix that markdown file being automatically parsed into html in proxy mode fix(handles): fix that when not a README file, markdown file being automatically parsed into html in proxy mode May 18, 2025
@xrgzs
Copy link
Contributor

xrgzs commented May 18, 2025

感觉这个功能的名称有问题,应该改为 过滤 Markdown 文件中的脚本 比较好,不然这个 PR 合并后点击其他带毒 Markdown 文件一样会 XSS。

https://alistgo.com/zh/config/preview.html#%E8%BF%87%E6%BB%A4-readme-%E6%96%87%E4%BB%B6%E4%B8%AD%E7%9A%84%E8%84%9A%E6%9C%AC

如果没过滤需求建议直接在设置中关掉。

@stephen-zeng
Copy link
Author

确实是的

@stephen-zeng
Copy link
Author

是否能通过单独判断下载请求和预览请求来解决误伤下载文件的问题,主要是因为在出口处全部渲染会导致所有获得md文件的途径都无法回去原始文件

@xrgzs
Copy link
Contributor

xrgzs commented May 18, 2025

是否能通过单独判断下载请求和预览请求来解决误伤下载文件的问题,主要是因为在出口处全部渲染会导致所有获得md文件的途径都无法回去原始文件

预览走/p路径,/d 请求的文件不会中转代理(挂载网盘转链的情况)。

@stephen-zeng
Copy link
Author

stephen-zeng commented May 18, 2025

是否能通过单独判断下载请求和预览请求来解决误伤下载文件的问题,主要是因为在出口处全部渲染会导致所有获得md文件的途径都无法回去原始文件

预览走/p路径,/d 请求的文件不会中转代理(挂载网盘转链的情况)。

那我知道了,因为没有判断/p/d路径导致下载的文件也是被解析过的,加个判断应该就好了
image

提交的代码没有输出debug,截图只是说明一下/d/p会走同一个出口。因为handle.Down直接将gin的context传给handle.Proxy,然后handle.Downhandle.Proxy都需要被传给gin,因此参数无法改变,所以只能通过gin的context来判断是/p还是/d了,暂时没想到更加优雅的通过添加参数来判断的方法。

@stephen-zeng stephen-zeng reopened this May 18, 2025
@stephen-zeng stephen-zeng changed the title fix(handles): fix that when not a README file, markdown file being automatically parsed into html in proxy mode fix(handles): fix that when downloading, markdown file will be parsed into html. May 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants