Fix REGEX_HELPER_OBJ_NAME round 2

This commit is contained in:
Jakub Filo 2024-12-17 21:13:41 +01:00
parent 23932bfa05
commit 3b0c081209
2 changed files with 4 additions and 5 deletions

View file

@ -34,7 +34,7 @@ pub static REGEX_SIGNATURE_FUNCTION: Lazy<Regex> = Lazy::new(|| {
r#")"#
)).unwrap()
});
pub static REGEX_HELPER_OBJ_NAME: &Lazy<Regex> = regex!(r"([A-Za-z0-9_\$]{1,})=function\(");
pub static REGEX_HELPER_OBJ_NAME: &Lazy<Regex> = regex!(r"function\(([a-zA-Z_$][a-zA-Z0-9_$]*)\)|([a-zA-Z_$][a-zA-Z0-9_$]*)\.[A-Za-z_$]");
pub static NSIG_FUNCTION_NAME: &str = "decrypt_nsig";
pub static SIG_FUNCTION_NAME: &str = "decrypt_sig";

View file

@ -182,10 +182,9 @@ pub async fn fetch_update(state: Arc<GlobalState>) -> Result<(), FetchUpdateStat
// Get the helper object
let helper_object_name = REGEX_HELPER_OBJ_NAME
.captures(sig_function_body)
.unwrap()
.get(1)
.unwrap()
.as_str();
.and_then(|cap| cap.get(1).or_else(|| cap.get(2)))
.map(|m| m.as_str())
.unwrap_or_default();
let mut helper_object_body_regex_str = String::new();
helper_object_body_regex_str += "(var ";