Skip to content

Commit 004e371

Browse files
committed
Don't double-encode file title
1 parent 2f335b3 commit 004e371

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/invidious/routes/video_playback.cr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ module Invidious::Routes::VideoPlayback
164164

165165
if title = query_params["title"]?
166166
# https://blog.fastmail.com/2011/06/24/download-non-english-filenames/
167-
env.response.headers["Content-Disposition"] = "attachment; filename=\"#{URI.encode_www_form(title)}\"; filename*=UTF-8''#{URI.encode_www_form(title)}"
167+
filename = URI.encode_www_form(title, space_to_plus: false)
168+
header = "attachment; filename=\"#{filename}\"; filename*=UTF-8''#{filename}"
169+
env.response.headers["Content-Disposition"] = header
168170
end
169171

170172
if !resp.headers.includes_word?("Transfer-Encoding", "chunked")

src/invidious/routes/watch.cr

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,9 @@ module Invidious::Routes::Watch
304304
end
305305

306306
download_widget = JSON.parse(selection)
307-
extension = download_widget["ext"].as_s
308307

309-
filename = URI.encode_www_form(
310-
"#{video_id}-#{title}.#{extension}",
311-
space_to_plus: false
312-
)
308+
extension = download_widget["ext"].as_s
309+
filename = "#{video_id}-#{title}.#{extension}"
313310

314311
# Pass form parameters as URL parameters for the handlers of both
315312
# /latest_version and /api/v1/captions. This avoids an un-necessary

0 commit comments

Comments
 (0)