greasyfork-org / greasyfork

An online repository of user scripts.
https://greasyfork.org
GNU General Public License v3.0
1.42k stars 426 forks source link

Webhook update not working for non-ASCII files (again) #1152

Closed YDX-2147483647 closed 1 year ago

YDX-2147483647 commented 1 year ago

Problem

I can't sync a file with non-ASCII name to GreasyFork with WebHook.

If I use an ASCII file name instead, it works.

Technical Reason

We use info[:urls] to identify scripts in app/controllers/concerns/webhooks.rb.

https://github.com/JasonBarnabe/greasyfork/blob/2c3a26d4f9457f49fd123998b2958cec90f45160/app/controllers/concerns/webhooks.rb#L118

But we don't encode the filenames in lib/github.rb.

https://github.com/JasonBarnabe/greasyfork/blob/2c3a26d4f9457f49fd123998b2958cec90f45160/lib/github.rb#L47-L55

Possible Fix

Note

Telling us not to use non-ASCII filenames (on https://greasyfork.org/import ) maybe easier and better.

I guess this is identical to #380 (in Aug 2015).

It was fixed by changing …

return path.gsub(' ', '%20')

… to …

re = Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")
return path.split('/').map{|part| URI.escape(part, re)}.join('/')

Days passed, and the file was totally refactored… There's no URI.escape in today's repo.

(This repo is 9 years old, thank you for maintaining GreasyFork!)

JasonBarnabe commented 1 year ago

It looks like it was indeed the encoding of the URL that was causing the problem. I've added code to handle it; let me know if it's still a problem for you.

YDX-2147483647 commented 1 year ago

Thanks! It works now. :tada:

{"updated_scripts":["https://greasyfork.org/zh-CN/scripts/466252-bit-%E8%A1%A5%E8%B6%B3%E9%A1%B5%E9%9D%A2%E6%A0%87%E9%A2%98"],"updated_failed":[]}