forked from neri/datatrash
fix: trim content before detecting urls
This commit is contained in:
parent
900d9ac449
commit
8f0cfdc91b
|
@ -416,7 +416,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "datatrash"
|
name = "datatrash"
|
||||||
version = "2.0.3"
|
version = "2.0.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-files",
|
"actix-files",
|
||||||
"actix-governor",
|
"actix-governor",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "datatrash"
|
name = "datatrash"
|
||||||
version = "2.0.3"
|
version = "2.0.4"
|
||||||
authors = ["neri"]
|
authors = ["neri"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ async fn build_text_response(path: &Path) -> Result<HttpResponse, Error> {
|
||||||
error::ErrorInternalServerError("this file should be here but could not be found")
|
error::ErrorInternalServerError("this file should be here but could not be found")
|
||||||
})?;
|
})?;
|
||||||
let encoded = htmlescape::encode_minimal(&content);
|
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);
|
let attribute_encoded = htmlescape::encode_attribute(&content);
|
||||||
URL_VIEW_HTML
|
URL_VIEW_HTML
|
||||||
.replace("{link_content}", &encoded)
|
.replace("{link_content}", &encoded)
|
||||||
|
|
Loading…
Reference in New Issue