Fix vulnerability founded by Paco Santos

This commit is contained in:
2026-03-08 18:47:54 +00:00
parent ad3e4024e5
commit 4947e1a800
2 changed files with 15 additions and 6 deletions

View File

@@ -4,11 +4,20 @@ use crate::rewrite_links::links_to_rewrite;
pub fn contain_links(msg: Message) -> bool {
match msg.text() {
Some(text) => links_to_rewrite::check_domains(String::from(text)),
Some(text) => links_to_rewrite::check_domains(get_domain(text)),
None => false,
}
}
pub fn get_domain(text: &str) -> String {
let s_text = String::from(text);
let split_array = s_text.split("/").collect::<Vec<_>>();
if split_array[0] == String::from("https:") && split_array[1].len() == 0 {
return split_array[2].to_string();
}
return String::new();
}
pub async fn fix_links(msg: Message, bot: Bot) -> anyhow::Result<()> {
let text = msg.text().unwrap();
let url_and_domain = links_to_rewrite::get_domain_from_text(String::from(text));

View File

@@ -3,11 +3,11 @@ use phf::phf_map;
use curl::easy::Easy;
static URLS: phf::Map<&'static str, (&'static str, bool)> = phf_map! {
"www.tiktok.com" => ("vxtiktok.com", false),
"vm.tiktok.com" => ("vxtiktok.com", true),
"vt.tiktok.com" => ("vxtiktok.com", true),
"lite.tiktok.com" => ("vxtiktok.com", true),
"www.instagram.com" => ("ddinstagram.com", false),
"www.tiktok.com" => ("kktiktok.com", false),
"vm.tiktok.com" => ("kktiktok.com", true),
"vt.tiktok.com" => ("kktiktok.com", true),
"lite.tiktok.com" => ("kktiktok.com", true),
"www.instagram.com" => ("kkinstagram.com", false),
"https://x.com" => ("https://fxtwitter.com", false),
"https://twitter.com" => ("https://fxtwitter.com",false),
};