Fix vulnerability founded by Paco Santos II

This commit is contained in:
2026-03-08 20:40:47 +00:00
parent 9fffb8c37f
commit ec0766abc5
2 changed files with 16 additions and 5 deletions

2
Cargo.lock generated
View File

@@ -1382,7 +1382,7 @@ dependencies = [
[[package]]
name = "mini_admin_bot"
version = "0.2.6"
version = "0.2.7"
dependencies = [
"anyhow",
"chrono",

View File

@@ -36,7 +36,7 @@ pub fn check_domains(text: String) -> bool {
pub fn get_domain_from_text(text: String) -> (String, String) {
for word in text.split(' ') {
for domain in URLS.keys() {
if get_domain(word.to_string()).contains(domain) {
if get_domain(word.to_string()).ends_with(domain) {
if URLS[domain].1 {
let url = match get_tiktok_redirection(String::from(word)) {
Ok(furl) => furl,
@@ -126,12 +126,23 @@ fn test_rewrite_instagram_message() {
}
#[test]
fn test_bad_redirect_instagram() {
fn test_bad_url_redirect_instagram() {
let url_and_domain =
get_domain_from_text("enlace: https://dominiofake.com/instagram.com espectacular".to_string());
let domain = filter_string(url_and_domain.0, url_and_domain.1);
assert_ne!(
assert_eq!(
domain,
Some("https://dominiofake.com/kkinstagram.com".to_string())
None
);
}
#[test]
fn test_bad_domain_redirect_instagram() {
let url_and_domain =
get_domain_from_text("enlace: https://www.instagram.com.pepe.es/reel/DJAE4JXSvHn/ espectacular".to_string());
let domain = filter_string(url_and_domain.0, url_and_domain.1);
assert_eq!(
domain,
None
);
}