Fix vulnerability founded by Paco Santos
This commit is contained in:
@@ -4,11 +4,20 @@ use crate::rewrite_links::links_to_rewrite;
|
|||||||
|
|
||||||
pub fn contain_links(msg: Message) -> bool {
|
pub fn contain_links(msg: Message) -> bool {
|
||||||
match msg.text() {
|
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,
|
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<()> {
|
pub async fn fix_links(msg: Message, bot: Bot) -> anyhow::Result<()> {
|
||||||
let text = msg.text().unwrap();
|
let text = msg.text().unwrap();
|
||||||
let url_and_domain = links_to_rewrite::get_domain_from_text(String::from(text));
|
let url_and_domain = links_to_rewrite::get_domain_from_text(String::from(text));
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ use phf::phf_map;
|
|||||||
use curl::easy::Easy;
|
use curl::easy::Easy;
|
||||||
|
|
||||||
static URLS: phf::Map<&'static str, (&'static str, bool)> = phf_map! {
|
static URLS: phf::Map<&'static str, (&'static str, bool)> = phf_map! {
|
||||||
"www.tiktok.com" => ("vxtiktok.com", false),
|
"www.tiktok.com" => ("kktiktok.com", false),
|
||||||
"vm.tiktok.com" => ("vxtiktok.com", true),
|
"vm.tiktok.com" => ("kktiktok.com", true),
|
||||||
"vt.tiktok.com" => ("vxtiktok.com", true),
|
"vt.tiktok.com" => ("kktiktok.com", true),
|
||||||
"lite.tiktok.com" => ("vxtiktok.com", true),
|
"lite.tiktok.com" => ("kktiktok.com", true),
|
||||||
"www.instagram.com" => ("ddinstagram.com", false),
|
"www.instagram.com" => ("kkinstagram.com", false),
|
||||||
"https://x.com" => ("https://fxtwitter.com", false),
|
"https://x.com" => ("https://fxtwitter.com", false),
|
||||||
"https://twitter.com" => ("https://fxtwitter.com",false),
|
"https://twitter.com" => ("https://fxtwitter.com",false),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user