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 encoding issue #125

Closed
wuyusite opened this issue Dec 15, 2024 · 5 comments
Closed

URL encoding issue #125

wuyusite opened this issue Dec 15, 2024 · 5 comments

Comments

@wuyusite
Copy link

May I ask how to encode the URL in the image and display it as normal Chinese content? Thank you and I look forward to your reply!
PixPin_2024-12-15_10-50-35

@9001
Copy link
Owner

9001 commented Dec 15, 2024

Hello :>

Currently, the log does not decode URLs, because this can make debugging more difficult. If there is an issue with a HTTP-Client failing to access a file, then it is more useful to have the original request for exact analysis.

But I realize that this can be an inconvenience for languages which are primarily non-ASCII, so maybe there should be a config option to decode URLs before displaying them in the log. Or, maybe it should always log both the original encoded URL and then also the decoded URL... I'll think about this, because it can be dangerous. On some platforms, decoding and displaying a malicious URL in a terminal can lead to RCE, so we must be careful: OSC9;7

For now, if you need to decode a specific URL, for example this:

04:05:41.168 GET /mu/doujin/c91/Halozy%20-%20%E7%8A%AC%E7%8C%AB%E7%9A%84%E9%9B%BB%E5%AD%90%E5%BA%A7%E6%9B%B2/08.%20%E3%82%A2%E3%82%B5%E3%83%92%20feat.%20emaru%20-%208%E7%95%AA%E7%9B%AE%E3%81%AE%E8%B7%AF%E5%9C%B0.opus?k=upfo&cache=987&_=1 plain 206 [40960-7077888],  6.71M 35.7M/s 6.72M 14.8M/s n1

...then you can do the following:

python3
Python 3.12.8 (main, Dec  7 2024, 05:56:13) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> s='/mu/doujin/c91/Halozy%20-%20%E7%8A%AC%E7%8C%AB%E7%9A%84%E9%9B%BB%E5%AD%90%E5%BA%A7%E6%9B%B2/08.%20%E3%82%A2%E3%82%B5%E3%83%92%20feat.%20emaru%20-%208%E7%95%AA%E7%9B%AE%E3%81%AE%E8%B7%AF%E5%9C%B0.opus?k=upfo&cache=987&_=1'
>>> from urllib.parse import unquote
>>> unquote(s)
'/mu/doujin/c91/Halozy - 犬猫的電子座曲/08. アサヒ feat. emaru - 8番目の路地.opus?k=upfo&cache=987&_=1'

Let's keep this issue open so the auto-decode option can be considered 👍

@wuyusite
Copy link
Author

Thank you for your reply. I roughly understand what you mean. I hope there will be a better solution to make copyparty more useful.

@9001 9001 closed this as completed in 73f7249 Dec 16, 2024
@9001
Copy link
Owner

9001 commented Dec 16, 2024

Alright, copyparty will now decode and print URLs if they contain any percent-encoded characters:

Screenshot_2024-12-16_00-12-16b-or8

00:11:32.734 127.0.0.1 34184  GET  /music/onoken%20feat.%20Rin%20-%20%E3%81%82%E3%81%84%E3%81%9F%E3%81%84.opus @*
00:11:32.735 127.0.0.1 34184   `-- 'music/onoken feat. Rin - あいたい.opus'
00:11:32.736 127.0.0.1 34184       /music/onoken%20feat.%20Rin%20-%20%E3%81%82%E3%81%84%E3%81%9F%E3%81%84.opus plain 200,  4.84M 1.26M/s 5.12M 1.04M/s n7

I am not sure when the next release will be, so I have attached a beta:

thank you for the idea, and please let me know if you encounter any further issues 👍

@wuyusite
Copy link
Author

Thank you for your efforts, and we look forward to the early release of a complete and stable version!

@wuyusite
Copy link
Author

After testing it, it seems to work very well. At least the server-side logs can be read better.

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

No branches or pull requests

2 participants