From 75f417f6590d98bb40304d254d61a9fca4bd2c39 Mon Sep 17 00:00:00 2001 From: tonhowtf Date: Fri, 31 Jul 2026 12:07:50 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20falso=20sucesso=20no=20login=20da=20Hotm?= =?UTF-8?q?art=20e=20erro=20de=20load=20de=20plugin=20sem=20c=C3=B3digo=20?= =?UTF-8?q?do=20OS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - auth_webview: o padrão de sucesso agora casa host exato/subdomínio (com prefixo de path opcional) em vez de substring em host+path — URLs do DoubleClick carregam o alvo do SSO como matrix params no path, sem percent-encoding, e disparavam falso sucesso no login da Hotmart (#269) - plugin_loader: a falha de load inclui a cadeia de erro do OS (126 dependência ausente, 5 acesso negado, 193 imagem inválida), antes engolida pelo Display do libloading, que só diz "LoadLibraryExW failed" (#265) --- src-tauri/src/commands/auth_webview.rs | 28 +++++++++++++++++--------- src-tauri/src/plugin_loader.rs | 12 ++++++++++- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src-tauri/src/commands/auth_webview.rs b/src-tauri/src/commands/auth_webview.rs index 280842c4..bfe9c768 100644 --- a/src-tauri/src/commands/auth_webview.rs +++ b/src-tauri/src/commands/auth_webview.rs @@ -89,18 +89,28 @@ pub async fn open_auth_webview( if let Some(ref pattern) = success_pattern { // An explicit success pattern from the plugin config is // authoritative: never fall back to the fuzzy heuristic. - // Match against host + path only, so encoded redirect params in - // the login URL itself (e.g. sso.hotmart.com/login?redirect= - // https%3A%2F%2Fconsumer.hotmart.com) can't trigger a false - // success. + // The pattern is `host` or `host/path-prefix`, and the host must + // match exactly or as a subdomain. A substring check over + // host+path is not enough: ad trackers like DoubleClick embed + // the SSO redirect target as semicolon matrix parameters, which + // live in the path with the target host not percent-encoded + // (e.g. /activityi;src=…;~oref=https://consumer.hotmart.com/…). if let Ok(nav_url) = url::Url::parse(&url_str) { - let host_and_path = - format!("{}{}", nav_url.host_str().unwrap_or(""), nav_url.path()); - if host_and_path.contains(pattern) { + let (pattern_host, pattern_path) = match pattern.split_once('/') { + Some((h, p)) => (h, Some(p)), + None => (pattern.as_str(), None), + }; + let nav_host = nav_url.host_str().unwrap_or(""); + let host_matches = !pattern_host.is_empty() + && (nav_host == pattern_host + || nav_host.ends_with(&format!(".{pattern_host}"))); + let path_matches = match pattern_path { + Some(p) => nav_url.path().trim_start_matches('/').starts_with(p), + None => true, + }; + if host_matches && path_matches { is_success = true; } - } else if url_str.contains(pattern) { - is_success = true; } } else if !login_host.is_empty() { if let Ok(nav_url) = url::Url::parse(&url_str) { diff --git a/src-tauri/src/plugin_loader.rs b/src-tauri/src/plugin_loader.rs index 7294b5d7..70e046b7 100644 --- a/src-tauri/src/plugin_loader.rs +++ b/src-tauri/src/plugin_loader.rs @@ -268,9 +268,19 @@ fn load_single_plugin( })?; let lib = unsafe { libloading::Library::new(&lib_path) }.map_err(|e| { + // libloading's Display is just "LoadLibraryExW failed"; the OS error + // code that says WHY (126 missing dependency, 5 access denied, 193 bad + // image) lives in the source chain and is what users need to report. + let mut detail = e.to_string(); + let mut source = std::error::Error::source(&e); + while let Some(s) = source { + detail.push_str(": "); + detail.push_str(&s.to_string()); + source = s.source(); + } PluginLoadError::simple( "library_load", - format!("Failed to load {}: {e}", lib_path.display()), + format!("Failed to load {}: {detail}", lib_path.display()), ) })?;