Merge pull request #47 from lifo9/fix-regex-helper-obj-name-2

Fix REGEX_HELPER_OBJ_NAME - round 2
This commit is contained in:
techmetx11 2024-12-17 20:21:56 +00:00 committed by GitHub
commit 74e879b54e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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 ";