Check index ID characters before making a dir with them
git-svn-id: file:///srv/svn/repo/kosuzu/trunk@30 eb64cd80-c68d-6f47-b6a3-0ada418499da
This commit is contained in:
parent
146d5c5f5d
commit
777a1c8aee
11
cli/pull.ml
11
cli/pull.ml
@ -86,6 +86,13 @@ let per_text url dir filter print i id time title authors topics = match id with
|
||||
|| Person.Set.exists (fun t -> List.mem (Person.to_string t) authors) filter.authors)
|
||||
then pull_text url dir id
|
||||
|
||||
let validate_id_length s = String.length s <= 32
|
||||
|
||||
let validate_id_chars s = try
|
||||
String.iter (function 'a'..'z'|'A'..'Z'|'0'..'9'-> () | _ -> raise (Invalid_argument "")) s;
|
||||
true
|
||||
with Invalid_argument _ -> false
|
||||
|
||||
let pull_index url authors_opt topics_opt =
|
||||
let index_url = url ^ "/index.pck" in
|
||||
match curl_pull index_url with
|
||||
@ -95,6 +102,10 @@ let pull_index url authors_opt topics_opt =
|
||||
| Error s -> Printf.printf "Error with %s: %s\n" url s; false
|
||||
| Ok pk when pk.info.id = "" ->
|
||||
Printf.printf "Empty ID index.pck, skipping %s\n" url; false
|
||||
| Ok pk when not (validate_id_length pk.info.id) ->
|
||||
Printf.printf "Index pack ID longer than 32 characters, skipping %s\n" url; false
|
||||
| Ok pk when not (validate_id_chars pk.info.id) ->
|
||||
Printf.printf "Index pack contains invalid ID characters, skipping %s\n" url; false
|
||||
| Ok pk ->
|
||||
let dir = Filename.concat Logarion.Peers.text_dir pk.info.id in
|
||||
Logarion.File_store.with_dir dir;
|
||||
|
Loading…
x
Reference in New Issue
Block a user