Skip to content

Commit 131d58c

Browse files
committed
Handle :: escapes properly; Fixes #134
1 parent 3cacb49 commit 131d58c

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

imageflow_server/src/main.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,8 @@ fn main() {
1919

2020

2121
fn parse_mount(s: &str) -> std::result::Result<MountLocation, String>{
22-
//.split permits empty elements. We just join consecutive empty elements to allow escaping of : via ::
23-
let mut parts = s.split(":").fold((Vec::new(),false), | (mut list, previous_empty), item| {
24-
if previous_empty && item.is_empty(){
25-
(list, false)
26-
}else if item.is_empty(){
27-
list.push(item.to_owned());
28-
(list, true)
29-
}else{
30-
list.push(item.to_owned());
31-
(list, false)
32-
}
33-
}).0;
34-
22+
//Escape ::
23+
let mut parts = s.replace("::","||||||").split(":").map(|s| s.replace("||||||",":")).collect::<Vec<String>>();
3524
if parts.len() < 2 {
3625
Err(format!("--mount prefix:engine:args Mount value must contain at least prefix:engine - received {:?} ({:?})", s, &parts))
3726
}else{

imageflow_server/tests/test_ir4.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,18 @@ fn run_server_test_i4(){
252252

253253
callback_result.unwrap();
254254
}
255+
{
256+
let c = context.subfolder_context("proxy");
257+
c.subfolder_context("proxy");
258+
let (po, callback_result) = ServerInstance::run(&c, Proto::Http, vec!["--data-dir=.", "--mount","/extern/:ir4_http:http:://images.unsplash.com/"], | server | {
259+
fetch_bytes(&server.url_for("/extern/photo-1422493757035-1e5e03968f95?width=100"))?;
260+
Ok(())
261+
});
262+
263+
//po.expect_status_code(Some(0));
264+
265+
callback_result.unwrap();
266+
}
255267
{
256268
let c = context.subfolder_context("mount_local"); //stuck on port 39876
257269
c.create_blank_image_here("eh", 100,100, s::EncoderPreset::libpng32());
@@ -432,4 +444,4 @@ impl ProcTestContextHttp for ProcTestContext{
432444
}
433445
}
434446

435-
}
447+
}

0 commit comments

Comments
 (0)