From c937a7fc04cb5f6693b7496318f35f2255d3bd70 Mon Sep 17 00:00:00 2001 From: nain <126972030+nain-F49FF806@users.noreply.github.com> Date: Fri, 26 Apr 2024 16:34:57 +0200 Subject: [PATCH] Do not trip on new warn before read feature Upstream privatebin introduced this new feature https://github.com/PrivateBin/PrivateBin/pull/1237 If the fragment contains a prefix character `-` , then the ui is supposed to warn before actyally getting paste, as the paste may be burn on read. This character can trip our reading of the bs58key. So, strip the prefix if found. --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 6b5da02..cf094de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,10 +28,13 @@ fn create_dataurl(path: &std::ffi::OsStr, data: String) -> String { fn handle_get(opts: &Opts) -> PbResult<()> { let url = opts.get_url(); let paste_id = opts.get_url().query().unwrap(); - let key = opts + let fragment = opts .get_url() .fragment() .ok_or(PasteError::MissingDecryptionKey)?; + // '-' character may be found at start of fragment. This should be stripped. + // It is used to activate "warn before read" feature for burn on read pastes. + let key = fragment.strip_prefix('-').unwrap_or(fragment); let api = API::new(url.clone(), opts.clone()); let paste = api.get_paste(paste_id)?;