From f37258f294919d7f374d86365056036c98382545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hozda?= Date: Tue, 18 Aug 2020 23:11:02 +0200 Subject: [PATCH] recognize more gopher types, fix validation and a minor error --- src/main.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3cad065..67162ed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,7 +68,7 @@ impl BrowserState { parsed_selector: String::new(), bookmarks: Vec::new(), config: Config { - start_uri: String::from("gopher://r-36.net:70"), + start_uri: String::from("gopher://gopher.floodgap.com:70"), cmd_text: String::from("less"), cmd_image: String::from("display"), cmd_browser: String::from("firefox"), @@ -306,14 +306,14 @@ impl BrowserState { } for line in buffer.lines() { - // if !is_valid_directory_entry(line.chars().next().unwrap_or('\0')) { - // println!( - // "error: not a directory: [{}] {}", - // line.chars().next().unwrap_or('\0'), - // line.chars().skip(1).collect::() - // ); - // return; - // } + if !is_valid_directory_entry(line.chars().next().unwrap_or('\0')) { + println!( + "invalid: [{}] {}", + line.chars().next().unwrap_or('\0'), + line.chars().skip(1).collect::() + ); + continue; + } self.handle_directory_line(line); } @@ -719,7 +719,7 @@ impl BrowserState { line.chars().skip(2).next().unwrap_or('\0'), )); }, - _ => { + x if !x.is_none() => { self.follow_link( make_key( line.chars().next().unwrap(), @@ -728,6 +728,7 @@ impl BrowserState { .unwrap_or(0), ); } + _ => (), } } /* never get's here but stops cc complaining */ @@ -818,7 +819,7 @@ pub fn make_key_str( pub fn is_valid_directory_entry(kind: char) -> bool { match kind { - 'i' | '3' | '.' | '0' | '1' | '5' | '7' | '8' | '9' | 'g' | 'I' | 'p' | 'h' + 'i' | '3' | '.' | '0' | '1' | '5' | '7' | '8' | '9' | 'g' | 'I' | 'p' | 'h' | '2' | 'd' | 's' => true, _ => false, }