From 8f0cfdc91b25799394161dec5752c4c5698ddfb9 Mon Sep 17 00:00:00 2001 From: neri Date: Thu, 26 Jan 2023 10:20:02 +0100 Subject: [PATCH] fix: trim content before detecting urls --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/download.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5fc6f17..f15d7df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -416,7 +416,7 @@ dependencies = [ [[package]] name = "datatrash" -version = "2.0.3" +version = "2.0.4" dependencies = [ "actix-files", "actix-governor", diff --git a/Cargo.toml b/Cargo.toml index a49bf15..e259380 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "datatrash" -version = "2.0.3" +version = "2.0.4" authors = ["neri"] edition = "2021" diff --git a/src/download.rs b/src/download.rs index 220e0f8..d872e49 100644 --- a/src/download.rs +++ b/src/download.rs @@ -127,7 +127,7 @@ async fn build_text_response(path: &Path) -> Result { error::ErrorInternalServerError("this file should be here but could not be found") })?; let encoded = htmlescape::encode_minimal(&content); - let html = if !content.contains(&['\n', '\r'][..]) && Url::from_str(&content).is_ok() { + let html = if !content.trim().contains(['\n', '\r']) && Url::from_str(content.trim()).is_ok() { let attribute_encoded = htmlescape::encode_attribute(&content); URL_VIEW_HTML .replace("{link_content}", &encoded)