Skip to content
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

[Bug]: 如果文件名包含#号,上传后返回的链接中#号没有转义为%23导致无法访问 #1121

Closed
3 tasks done
iamqiz opened this issue May 4, 2023 · 5 comments
Assignees
Labels

Comments

@iamqiz
Copy link

iamqiz commented May 4, 2023

前置阅读 | Pre-reading

PicGo的版本 | PicGo Version

2.3.1

系统信息 | System Information

Windows

问题重现 | Bug reproduce

将图片改名,使其含有#号
上传图片
返回的的url无法访问, 需要把#号改成%23才能访问

相关日志 | Logs

No response

@Molunerfinn
Copy link
Owner

Molunerfinn commented May 5, 2023

#号在 URL 是作为一个合法的 hash 标识符,前端通过 encodeURI 是不会转义这个字符的。建议不要取名带有 # 号标识。

因为有些云服务商是通过 ?xxx 或者 #xxx 来对图片做一些额外处理(比如压缩图片等),这个时候是不能转义这些 URL 里合法标识的。

@Molunerfinn
Copy link
Owner

参考 #996 ,无法做所有的字符转义也是有原因的

@iamqiz
Copy link
Author

iamqiz commented May 5, 2023

picgo上传之后,腾讯云返回的链接就是没有编码#的链接? 我在腾讯云控制台复制的链接是转义过的,不存在#号

@iamqiz
Copy link
Author

iamqiz commented May 5, 2023

我刚才试了腾讯云的nodejs api上传文件,成功之后返回的url是编码过#号的,
比如
key 设置为 '美国/#ss.jpeg'
返回的url 结尾为

myqcloud.com/%E7%BE%8E%E5%9B%BD/%23ss.jpeg',

也就是说上传的时候,可以指定文件名(key参数), 返回结果会对特殊符号进行编码,
picgo是对返回的url进行解码之后再进行 encodeURI ? 😂

@Molunerfinn
Copy link
Owner

应该是它对文件名做了encodeURIComponent操作,这个跟encodeURI不一样。

我看看后续版本里做一下处理吧

Molunerfinn added a commit that referenced this issue May 7, 2023
Molunerfinn added a commit that referenced this issue May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants