Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/script_steps/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ pub enum ScriptStep {
ResetAccountPassword = 136,
EnableAccount = 137,
ReLogin = 138,
InsertFromURL = 160,
OpenManageThemes = 165,
RefreshObject = 167,
ClosePopover = 169,
Expand Down
192 changes: 192 additions & 0 deletions src/script_steps/insert_from_url.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
use quick_xml::Reader;
use quick_xml::events::Event;

use crate::script_steps::parameters::boolean::Boolean;
use crate::script_steps::parameters::calculation::Calculation;
use crate::script_steps::parameters::target::Target;
use crate::utils::attributes::get_attribute;

const VERIFY_SSL_CERTIFICATES: &str = "268435456";
const SELECT: &str = "4096";
const WITH_DIALOG: &str = "128";

pub fn sanitize(step: &str) -> Option<String> {
let mut name = String::new();
let mut select: Option<String> = None;
let mut with_dialog: Option<String> = None;
let mut target: Option<String> = None;
let mut url: Option<String> = None;
// "Verify SSL Certificates" is shown by name only when enabled, mirroring FileMaker.
let mut verify_ssl: Option<String> = None;
let mut curl_options: Option<String> = None;

let mut reader = Reader::from_str(step);
let mut buf = Vec::new();
loop {
match reader.read_event_into(&mut buf) {
Err(_) => continue,
Ok(Event::Eof) => break,
Ok(Event::Start(e)) => match e.name().as_ref() {
b"Step" => {
name = get_attribute(&e, "name").unwrap_or_default();
}
b"Boolean" => {
let id = get_attribute(&e, "id").unwrap_or_default();
let label = get_attribute(&e, "type").unwrap_or_default();
let is_on = get_attribute(&e, "value").as_deref() == Some("True");
match id.as_str() {
VERIFY_SSL_CERTIFICATES if is_on => verify_ssl = Some(label),
SELECT if is_on => select = Some(label),
WITH_DIALOG => {
with_dialog = Some(format!("{label}: {}", Boolean::on_off(is_on)))
}
_ => {}
}
}
b"Parameter" => match get_attribute(&e, "type").as_deref() {
Some("Target") => target = Target::from_xml(&mut reader, &e).display(),
Some("URL") => {
url = Calculation::from_xml(&mut reader, &e)
.display()
.map(|c| format!("URL: {c}"))
}
Some("Calculation") => {
curl_options = Calculation::from_xml(&mut reader, &e)
.display()
.map(|c| format!("cURL options: {c}"))
}
_ => {}
},
_ => {}
},
_ => {}
}
buf.clear();
}

if name.is_empty() {
return None;
}

let parts: Vec<String> = [
select,
with_dialog,
target.map(|t| format!("Target: {t}")),
url,
verify_ssl,
curl_options,
]
.into_iter()
.flatten()
.collect();

if parts.is_empty() {
Some(name)
} else {
Some(format!("{name} [ {} ]", parts.join(" ; ")))
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn empty_url() {
let xml = r#"
<Step index="11" id="160" name="Insert from URL" enable="True">
<ParameterValues membercount="4">
<Parameter type="Boolean">
<Boolean type="Verify SSL Certificates" id="268435456" value="False"></Boolean>
</Parameter>
<Parameter type="Boolean">
<Boolean type="Select" id="4096" value="True"></Boolean>
</Parameter>
<Parameter type="Boolean">
<Boolean type="With dialog" id="128" value="False"></Boolean>
</Parameter>
<Parameter type="URL">
<URL autoEncode="True"></URL>
</Parameter>
</ParameterValues>
</Step>
"#;

let expected_output = Some("Insert from URL [ Select ; With dialog: OFF ]".to_string());
assert_eq!(sanitize(xml.trim()), expected_output);
}

#[test]
fn full_with_verify_ssl_and_curl() {
let xml = r#"
<Step index="0" id="160" name="Insert from URL" enable="True">
<ParameterValues membercount="6">
<Parameter type="Boolean">
<Boolean type="Verify SSL Certificates" id="268435456" value="True"></Boolean>
</Parameter>
<Parameter type="Boolean">
<Boolean type="Select" id="4096" value="True"></Boolean>
</Parameter>
<Parameter type="Boolean">
<Boolean type="With dialog" id="128" value="False"></Boolean>
</Parameter>
<Parameter type="Target">
<Variable value="$response">
<repetition value="1"></repetition>
</Variable>
</Parameter>
<Parameter type="URL">
<URL autoEncode="False">
<Calculation datatype="1" position="0">
<Calculation>
<Text><![CDATA[$url]]></Text>
</Calculation>
</Calculation>
</URL>
</Parameter>
<Parameter type="Calculation">
<Calculation datatype="1" position="1">
<Calculation>
<Text><![CDATA[$curl]]></Text>
</Calculation>
</Calculation>
</Parameter>
</ParameterValues>
</Step>
"#;

let expected_output = Some("Insert from URL [ Select ; With dialog: OFF ; Target: $response ; URL: $url ; Verify SSL Certificates ; cURL options: $curl ]".to_string());
assert_eq!(sanitize(xml.trim()), expected_output);
}

#[test]
fn url_without_target_or_curl() {
let xml = r#"
<Step index="0" id="160" name="Insert from URL" enable="True">
<ParameterValues membercount="4">
<Parameter type="Boolean">
<Boolean type="Verify SSL Certificates" id="268435456" value="False"></Boolean>
</Parameter>
<Parameter type="Boolean">
<Boolean type="Select" id="4096" value="False"></Boolean>
</Parameter>
<Parameter type="Boolean">
<Boolean type="With dialog" id="128" value="True"></Boolean>
</Parameter>
<Parameter type="URL">
<URL autoEncode="True">
<Calculation datatype="1" position="0">
<Calculation>
<Text><![CDATA[$url]]></Text>
</Calculation>
</Calculation>
</URL>
</Parameter>
</ParameterValues>
</Step>
"#;

let expected_output = Some("Insert from URL [ With dialog: ON ; URL: $url ]".to_string());
assert_eq!(sanitize(xml.trim()), expected_output);
}
}
1 change: 1 addition & 0 deletions src/script_steps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod exit_script;
mod go_to_object;
mod go_to_portal_row;
mod go_to_record;
mod insert_from_url;
mod insert_text;
mod is_enabled;
mod omit_multiple_records;
Expand Down
1 change: 1 addition & 0 deletions src/script_steps/sanitizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub fn sanitize(step_id: u32, step_xml: &str, flags: &Flags) -> Option<String> {
script_steps::perform_find::sanitize(step_xml)
}
ScriptStep::InsertText => script_steps::insert_text::sanitize(step_xml),
ScriptStep::InsertFromURL => script_steps::insert_from_url::sanitize(step_xml),
ScriptStep::SetField => script_steps::set_field_data::sanitize(step_xml),
ScriptStep::ReplaceFieldContents => {
script_steps::replace_field_contents::sanitize(step_xml)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Variable setzen [ $curloptions ; " --request DELETE" &
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]

# inspect result
Variable setzen [ $my.response ; Austauschen ( HoleWert ( $$my.headers ; 1 ) ; "HTTP/1.1 " ; "" ) ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Ende (wenn)
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]

# inspect result
Variable setzen [ $my.response ; Austauschen ( HoleWert ( $$my.headers ; 1 ) ; "HTTP/1.1 " ; "" ) ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Variable setzen [ $$API.UPDATE ; "1" ]
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]

Variable setzen [ $my.certpath ; JSONGetElement ( $$my.result ; "response.csrFilePath" ) ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Variable setzen [ $$API.UPDATE ; "1" ]
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]

# -------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Variable setzen [ $curloptions ; " --request GET" &
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]

Wenn [ Hole ( ScriptErgebnis ) = "1" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Variable setzen [ $$API.UPDATE ; "1" ]
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]

# -------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Sonst, wenn [ $_param = "disconnect" ]
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]
# update database listing
Script ausführen [ "List Clients" ; Specified: Aus Liste ; Parameter: ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Variable setzen [ $curloptions ; " --request GET" &
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]

Wenn [ Hole ( ScriptErgebnis ) = "1" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Sonst, wenn [ $_param = "send" ]
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]
Ende (wenn)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Variable setzen [ $$API.UPDATE ; "1" ]
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]

Wenn [ Hole ( ScriptErgebnis ) = "1" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Variable setzen [ $$API.UPDATE ; "1" ]
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]

# -------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Variable setzen [ $$API.UPDATE ; "1" ]
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]

Wenn [ Hole ( ScriptErgebnis ) = "1" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Wenn [ NICHT IstLeer ( PUB__publickeys::dateAdded ) ]
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]

Wenn [ Hole ( ScriptErgebnis ) = "1" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Variable setzen [ $$API.UPDATE ; "1" ]
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]

Wenn [ Hole ( ScriptErgebnis ) = "1" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Variable setzen [ $$API.UPDATE ; "1" ]
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]

# -------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Variable setzen [ $curloptions ; " --request GET" &
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]

Wenn [ Hole ( ScriptErgebnis ) = "1" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Variable setzen [ $curloptions ; " --request GET" &
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]

Wenn [ Hole ( ScriptErgebnis ) = "1" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Variable setzen [ $curloptions ; " --request GET" &
# -------------------------------------------------------------
# PROCESS
# -------------------------------------------------------------
Aus URL einfügen [ SSL-Zertifikate verifizieren: OFF ; Auswahl: ON ; Mit Dialog: OFF ; Target: $$my.result ; ⚠️ PARAMETER "URL" NOT PARSED ⚠️ ; $curloptions ]
Aus URL einfügen [ Auswahl ; Mit Dialog: OFF ; Target: $$my.result ; URL: $$server & $endpoint ; cURL options: $curloptions ]
Script ausführen [ "Handle response" ; Specified: Aus Liste ; Parameter: ]

Wenn [ Hole ( ScriptErgebnis ) = "1" ]
Expand Down
Loading
Loading