Fix vulnerability founded by Paco Santos II
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1382,7 +1382,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mini_admin_bot"
|
name = "mini_admin_bot"
|
||||||
version = "0.2.6"
|
version = "0.2.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ pub fn check_domains(text: String) -> bool {
|
|||||||
pub fn get_domain_from_text(text: String) -> (String, String) {
|
pub fn get_domain_from_text(text: String) -> (String, String) {
|
||||||
for word in text.split(' ') {
|
for word in text.split(' ') {
|
||||||
for domain in URLS.keys() {
|
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 {
|
if URLS[domain].1 {
|
||||||
let url = match get_tiktok_redirection(String::from(word)) {
|
let url = match get_tiktok_redirection(String::from(word)) {
|
||||||
Ok(furl) => furl,
|
Ok(furl) => furl,
|
||||||
@@ -126,12 +126,23 @@ fn test_rewrite_instagram_message() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_bad_redirect_instagram() {
|
fn test_bad_url_redirect_instagram() {
|
||||||
let url_and_domain =
|
let url_and_domain =
|
||||||
get_domain_from_text("enlace: https://dominiofake.com/instagram.com espectacular".to_string());
|
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);
|
let domain = filter_string(url_and_domain.0, url_and_domain.1);
|
||||||
assert_ne!(
|
assert_eq!(
|
||||||
domain,
|
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
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user