aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-05-27 01:47:14 -0700
committerFuwn <[email protected]>2024-05-27 01:47:24 -0700
commitecc71106abc90f88728111de1b0e90b5112b74a9 (patch)
tree8e4bf97cfb68cc09ded4a022af710c3a51fe1002 /src/modules
parentfeat(router): remove translation engine (diff)
downloadlocus-ecc71106abc90f88728111de1b0e90b5112b74a9.tar.xz
locus-ecc71106abc90f88728111de1b0e90b5112b74a9.zip
fix(web): escape september and kineto proxy information
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/web.rs58
1 files changed, 35 insertions, 23 deletions
diff --git a/src/modules/web.rs b/src/modules/web.rs
index 2a0bce6..b0d6b40 100644
--- a/src/modules/web.rs
+++ b/src/modules/web.rs
@@ -82,13 +82,18 @@ To visit the web version of this exact page, <https://fuwn.me/web>, you would vi
};
let parser = dom.parser();
let mut nodes = dom.nodes().iter().peekable();
+ let mut in_proxy_information = false;
while let Some(element) = nodes.next() {
let mut text = String::new();
let () = element.as_tag().map_or((), |tag| {
match tag.name().as_utf8_str().to_string().as_str() {
- "p" => {
+ "p" if !in_proxy_information => {
+ if tag.inner_html(parser).contains("<img") {
+ return;
+ }
+
contents.push(format!(
"{}\n\n",
tag
@@ -99,7 +104,7 @@ To visit the web version of this exact page, <https://fuwn.me/web>, you would vi
.unwrap_or(&"A parse error occurred in this location.")
));
}
- "a" => {
+ "a" if !in_proxy_information => {
contents.pop();
contents.push(format!(
"=> {} {}\n{}",
@@ -121,52 +126,59 @@ To visit the web version of this exact page, <https://fuwn.me/web>, you would vi
})
));
}
- "h1" => {
+ "h1" if !in_proxy_information => {
contents.push(format!("# {}\n\n", tag.inner_text(parser)));
}
- "h2" => {
+ "h2" if !in_proxy_information => {
contents.push(format!("## {}\n\n", tag.inner_text(parser)));
}
- "h3" => {
+ "h3" if !in_proxy_information => {
contents.push(format!("### {}\n\n", tag.inner_text(parser)));
}
- "pre" => {
+ "pre" if !in_proxy_information => {
contents.push(format!("```\n{}```\n", tag.inner_text(parser)));
}
- "blockquote" => {
+ "blockquote" if !in_proxy_information => {
contents.push(format!("> {}\n\n", tag.inner_text(parser)));
}
- "li" => {
+ "li" if !in_proxy_information => {
contents.push(format!("* {}\n", tag.inner_text(parser)));
}
"html" | "head" | "script" | "link" | "title" | "body" | "ul"
- | "style" => {}
+ | "style"
+ if !in_proxy_information => {}
_ => {
text = tag.inner_text(parser).to_string();
- if text.contains("Proxy information")
- || text.contains("Proxied content from")
+ if (text.contains("Proxy Information")
+ || text.contains("Proxied content from"))
+ && tag.inner_html(parser).contains("<summary>")
{
+ in_proxy_information = true;
+
return;
}
- println!(
- "{}: {}",
- tag.name().as_utf8_str(),
- tag.inner_text(parser)
- );
+ if (text.contains("This content has been proxied by September")
+ || text.contains(
+ "Be advised that no attempt was made to verify the remote \
+ SSL certificate.",
+ ))
+ && in_proxy_information
+ {
+ in_proxy_information = false;
+
+ return;
+ }
+
+ if in_proxy_information {
+ return;
+ }
contents.push(format!("{}\n\n", tag.inner_text(parser)));
}
}
});
-
- // Covers September and Kineto
- if text == "Proxy information"
- || text.contains("Proxied content from")
- {
- break;
- }
}
contents.join("")