pull/1/head
chris west 4 years ago
parent aeaf8d36c4
commit 1a102fa9a8

@ -16,7 +16,7 @@ impl Request {
pub fn from(host: &str, port: u16, root: &str) -> Result<Request> {
Ok(Request {
host: host.into(),
port: port,
port,
root: fs::canonicalize(root)?.to_string_lossy().into(),
selector: String::new(),
query: String::new(),
@ -43,7 +43,7 @@ impl Request {
self.query.clear();
self.selector.clear();
if let Some(i) = line.find('\t') {
if line.len() >= i + 1 {
if line.len() > i {
self.query.push_str(&line[i + 1..]);
self.selector.push_str(&line[..i]);
return;

@ -167,7 +167,7 @@ where
)?;
}
let mut footer = path.clone();
let mut footer = path;
footer.push_str("/footer.gph");
if fs_exists(&footer) {
let mut sel = req.selector.clone();
@ -251,7 +251,7 @@ fn gph_line_to_gopher(line: &str, req: &Request) -> String {
return "".to_string();
}
let mut line = line.trim_end_matches("\r").to_string();
let mut line = line.trim_end_matches('\r').to_string();
if line.starts_with('[') && line.ends_with(']') && line.contains('|') {
// [1|name|sel|server|port]
let port = req.port.to_string();

Loading…
Cancel
Save