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

对象存储访问存在访问含中文字符的url不正确 #154

Closed
ertuil opened this issue Jan 22, 2024 · 5 comments · Fixed by #156
Closed

对象存储访问存在访问含中文字符的url不正确 #154

ertuil opened this issue Jan 22, 2024 · 5 comments · Fixed by #156

Comments

@ertuil
Copy link

ertuil commented Jan 22, 2024

在使用中发现,moememos可能存在对含有中文字符(或unicode)的url请求处理不正确,对‘%’符号进行了双重编码:

正确的url: <OSS接入点>/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%.png
MoeMemos 发出的错误URL:<OSS接入点>/%25E5%25B1%258F%25E5%25B9%2595%25E6%2588%25AA%25E5%259B%25BE%.png

疑似将‘%’ 再次编码为 %25

@Issues-translate-bot
Copy link

Issue is not in English. It has been translated automatically.


Title: Object storage access has incorrect access to URLs containing Chinese characters.

During use, it was found that moememos may have incorrectly processed URL requests containing Chinese characters (or unicode) and double-encoded the '%' symbol:

Correct url: <OSS access point>/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%.png
Error URL sent by MoeMemos: <OSS access point>/%25E5%25B1%258F%25E5%25B9%2595%25E6%2588%25AA%25E5%259B%25BE%.png

It is suspected that ‘%’ is encoded again as %25

@mudkipme
Copy link
Owner

Please provide your Memos server version and examples of the externalLink field in your /api/v1/resource response.

Moe Memos does re-encode parts of externalLink due to the lack of proper URL encoding in Memos API, which I can still reproduce with Memos 0.18.2 and object storage service.

The response of /api/v1/resource in my Memos instance is:

[
  {
    ...
    "externalLink": "https://<oss access point>/2024/01/1705950677_测试.jpeg"
    ...
  }
]

@ertuil
Copy link
Author

ertuil commented Jan 23, 2024

I am now using Memos 0.18.2, and my externalLink would be:

"externalLink": "https://<oss access point>/uploads/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202024-01-19%20105653.png"

@ertuil
Copy link
Author

ertuil commented Jan 23, 2024

I am using Aliyun OSS, it seems that Aliyun OSS will convert the URLs automatically.
For example, if I upload a file named "测试.png" (even not using Memos), the returned access URL will be:

https://<oss access point>/%E6%B5%8B%E8%AF%95.jpg

@mudkipme
Copy link
Owner

mudkipme commented Jan 23, 2024

Thank you for providing the information!

I've figured out that it relates to how Memos writes ExternalLink differently based on whether "URL Prefix" is used in the storage settings or not.

I'll remove the additional URL encoding in Moe Memos and separately open an issue/pull request in the Memos repository to add percent-encoding for ExternalLink when "URL Prefix" is used.

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 a pull request may close this issue.

3 participants