Skip to content

Commit

Permalink
Ensure temporary files are given legal filenames (ygrek#126)
Browse files Browse the repository at this point in the history
The short_file value for some URLs may result in the string "/". For
example, this URL:

http://te-home.net/?do=hublist&get=hublist.config.bz2

results in:

short_file: /
full_file: /?do=hublist&get=hublist.config.bz2

this makes it impossible to save the file. With this change, a random
file name is chosen.
  • Loading branch information
carlonluca committed Jan 30, 2025
1 parent 338e426 commit ab3bf66
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/net/http_client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ let wget r f =

let base = Filename.basename r.req_url.Url.short_file in
(* Base could be "." for http://site.com/ *)
let base = if base = "."
let base = if base = "." || base = "/"
then begin
let prng = Random.State.make_self_init () in
let rnd = (Random.State.bits prng) land 0xFFFFFF in
Expand Down

0 comments on commit ab3bf66

Please sign in to comment.