From 42d7c204c10e3efcb980910db94226474684da84 Mon Sep 17 00:00:00 2001 From: "James C. Wise" Date: Fri, 2 Aug 2024 22:01:20 -0400 Subject: [PATCH] out.reddit.com, cargo upgrade+update, e.emailalerts.cnn.com now no longer uses HTTP --- Cargo.lock | 54 +++++++++++++++++--------------- Cargo.toml | 8 ++--- default-config.json | 38 ++++++++++++++-------- src/types/string_modification.rs | 26 +++++++++++++-- 4 files changed, 81 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1bdfb16..8f12c5d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -139,15 +139,15 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytes" -version = "1.6.1" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cc" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" [[package]] name = "cfg-if" @@ -157,9 +157,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.11" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3" +checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" dependencies = [ "clap_builder", "clap_derive", @@ -167,9 +167,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.11" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa" +checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" dependencies = [ "anstream", "anstyle", @@ -179,9 +179,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.11" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ "heck", "proc-macro2", @@ -678,9 +678,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", "hashbrown", @@ -951,9 +951,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -1170,11 +1170,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1274,12 +1275,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", "windows-sys 0.52.0", ] @@ -1352,9 +1354,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.1" +version = "1.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d040ac2b29ab03b09d4129c2f5bbd012a3ac2f79d38ff506a4bf8dd34b0eac8a" +checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" dependencies = [ "backtrace", "bytes", @@ -1388,9 +1390,9 @@ dependencies = [ [[package]] name = "tokio-socks" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0" +checksum = "0d4770b8024672c1101b3f6733eab95b18007dbe0847a8afe341fcf79e06043f" dependencies = [ "either", "futures-util", @@ -1541,9 +1543,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "want" @@ -1638,9 +1640,9 @@ dependencies = [ [[package]] name = "which" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7" +checksum = "3d9c5ed668ee1f17edb3b627225343d210006a90bb1e3745ce1f30b1fb115075" dependencies = [ "either", "home", diff --git a/Cargo.toml b/Cargo.toml index 29fffe8..4eb6ac0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,21 +11,21 @@ license = "AGPL-3.0-or-later" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -clap = { version = "4.5.11", features = ["derive", "unstable-v5"] } +clap = { version = "4.5.13", features = ["derive", "unstable-v5"] } serde = { version = "1.0.204", features = ["derive"] } -serde_json = "1.0.120" +serde_json = "1.0.122" url = { version = "2.5.2", features = ["serde"] } reqwest = { version = "0.12.5", features = ["blocking", "socks"], optional = true } const-str = { version = "0.5.7", optional = true } atty = { version = "0.2.14", optional = true } thiserror = "1.0.63" -regex = { version = "1.10.5", optional = true } +regex = { version = "1.10.6", optional = true } glob = { version = "0.3.1", optional = true } psl = "2.1.55" form_urlencoded = "1.2.1" regex-syntax = { version = "0.8.4", optional = true } percent-encoding = "2.3.1" -which = { version = "6.0.1", optional = true } +which = { version = "6.0.2", optional = true } base64 = "0.22.1" diesel = { version = "2.2.2", features = ["sqlite", "returning_clauses_for_sqlite_3_35"], optional = true } diff --git a/default-config.json b/default-config.json index 614dab3..a6ef44c 100644 --- a/default-config.json +++ b/default-config.json @@ -18,13 +18,13 @@ "shortlink-hosts": [ "a.co", "abc7.la", "adobe.ly", "aje.io", "amzn.asia", "amzn.to", "apple.co", "bbc.in", "bit.ly", "bitly.com", "bitly.com", "bityl.co", "blizz.ly", "bloom.bg", "boxd.it", "buff.ly", "cbsn.ws", "cfl.re", "chn.ge", "chng.it", "cnb.cx", "cnn.it", "cos.lv", "cutt.ly", - "db.tt", "dcdr.me", "dis.gd", "dlvr.it", "e.emailalerts.cnn.com", "etsy.me", "fal.cn", "fb.me", "flip.it", "forms.gle", "g.co", + "db.tt", "dcdr.me", "dis.gd", "dlvr.it", "etsy.me", "fal.cn", "fb.me", "flip.it", "forms.gle", "g.co", "glo.bo", "go.forbes.com", "go.nasa.gov", "gofund.me", "goo.gl", "goo.su", "gum.co", "hulu.tv", "ift.tt", "iwe.one", "j.mp", "k00.fr", - "katy.to", "kck.st", "l.leparisien.fr", "link.animaapp.com", "linkr.it", "lnk.to", "loom.ly", "mzl.la", "n.pr", "nas.cr", "ninten.do", - "ntdo.co.uk", "ny.ti", "nyer.cm", "nyti.ms", "nyto.ms", "on.forbes.com", "on.ft.com", "on.msnbc.com", "onl.bz", "onl.la", "onl.sc", - "operagx.gg", "orlo.uk", "ow.ly", "pin.it", "pixiv.me", "play.st", "py.pl", "rb.gy", "rblx.co", "rdbl.co", "redd.it", "reurl.cc", - "reut.rs", "rzr.to", "s.goodsmile.link", "shorturl.at", "spoti.fi", "spr.ly", "sqex.to", "t.co", "t.ly", "thecutio", "thr.cm", - "tmz.me", "tr.ee", "trib.al", "wn.nr", "wwdc.io", "x.gd", "xbx.ly", "xhslink.com", "yrp.ca" + "katy.to", "kck.st", "l.leparisien.fr", "link.animaapp.com", "linkr.it", "lnk.to", "loom.ly", "msft.it", "mzl.la", "n.pr", "nas.cr", + "ninten.do", "ntdo.co.uk", "ny.ti", "nyer.cm", "nyti.ms", "nyto.ms", "on.forbes.com", "on.ft.com", "on.msnbc.com", "onl.bz", "onl.la", + "onl.sc", "operagx.gg", "orlo.uk", "ow.ly", "pin.it", "pixiv.me", "play.st", "py.pl", "rb.gy", "rblx.co", "rdbl.co", "redd.it", + "reurl.cc", "reut.rs", "rzr.to", "s.goodsmile.link", "shorturl.at", "spoti.fi", "spr.ly", "sqex.to", "t.co", "t.ly", "thecutio", + "thr.cm", "tmz.me", "tr.ee", "trib.al", "wn.nr", "wwdc.io", "x.gd", "xbx.ly", "xhslink.com", "yrp.ca" ], "utps": [ "Tcsack", "__hsfp", "__hssc", "__hstc", "__io_lv", "__s", "_branch_match_id", "_branch_referrer", "_clde", "_cldee", "_ga", @@ -160,11 +160,11 @@ {"InSet": "bypass.vip-hosts"}, {"IsOneOf": [ "allmylinks.com", "api.linkr.bio", "api.pinterest.com", "bfy.tw", "buymeacoff.ee", "buymeacoffee.com", "cach.me", "cash.app", - "deviantart.com", "duckduckgo.com", "duckduckgo.com", "duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion", "gf.me", - "gofundme.com", "gofundme.com", "google.com", "gprivate.com", "href.li", "instagr.am", "instagram.com", "l.instagram.com", - "l.threads.com", "lmddgtfy.net", "lnk.bio", "out.reddit.com", "pawoo.net", "pixiv.net", "preview.tinyurl.com", "sketchfab.com", - "sketchfab.com", "skfb.ly", "smarturl.it", "steamcommunity.com", "subscribestar.adult", "t.umblr.com", "tinyurl.com", "toyhou.se", - "youtube.com" + "deviantart.com", "duckduckgo.com", "duckduckgo.com", "duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion", + "e.emailalerts.cnn.com", "gf.me", "gofundme.com", "gofundme.com", "google.com", "gprivate.com", "href.li", "instagr.am", "instagram.com", + "l.instagram.com", "l.threads.com", "lmddgtfy.net", "lnk.bio", "out.reddit.com", "pawoo.net", "pixiv.net", "preview.tinyurl.com", + "sketchfab.com", "sketchfab.com", "skfb.ly", "smarturl.it", "steamcommunity.com", "subscribestar.adult", "t.umblr.com", "tinyurl.com", + "toyhou.se", "youtube.com" ]}, {"InSet": "lmgtfy-hosts"}, {"LengthIs": 4}, @@ -465,7 +465,19 @@ }} ]} }}, - "out.reddit.com": {"GetUrlFromQueryParam": "url"} + "out.reddit.com": {"GetUrlFromQueryParam": "url"}, + "e.emailalerts.cnn.com": {"SetPart": { + "part": "Whole", + "value": {"Modified": { + "source": {"Part": "Query"}, + "modification": {"All": [ + {"KeepNthSegment": {"split": "/", "n": 2}}, + {"Remove": 0}, + "Base64DecodeStandardNoPad", + {"KeepNthSegment": {"split": ",", "n": -1}} + ]} + }} + }} } } }, @@ -1045,7 +1057,7 @@ "PartMap": { "part": "Path", "map": { - "/search": {"AllowQueryParams": ["hl", "q", "tbm", "p", "udm"]}, + "/search": {"AllowQueryParams": ["hl", "q", "tbm", "p", "udm", "filter"]}, "/setprefs": {"RemoveQueryParams": ["sa", "ved"]} } } diff --git a/src/types/string_modification.rs b/src/types/string_modification.rs index df8fb80..c02693f 100644 --- a/src/types/string_modification.rs +++ b/src/types/string_modification.rs @@ -775,6 +775,14 @@ pub enum StringModification { /// /// If the call to [`String::from_utf8`] returns an error, that error is returned. Base64DecodeStandard, + /// Encode the string using [`base64::prelude::BASE64_STANDARD_NO_PAD`]. + Base64EncodeStandardNoPad, + /// Decode the string using [`base64::prelude::BASE64_STANDARD_NO_PAD`]. + /// # Errors + /// If the call to [`base64::engine::Engine::decode`] returns an error, that error is returned. + /// + /// If the call to [`String::from_utf8`] returns an error, that error is returned. + Base64DecodeStandardNoPad, /// Encode the string using [`base64::prelude::BASE64_URL_SAFE`]. Base64EncodeUrlSafe, /// Encode the string using [`base64::prelude::BASE64_URL_SAFE`]. @@ -783,6 +791,14 @@ pub enum StringModification { /// /// If the call to [`String::from_utf8`] returns an error, that error is returned. Base64DecodeUrlSafe, + /// Encode the string using [`base64::prelude::BASE64_URL_SAFE_NO_PAD`]. + Base64EncodeUrlSafeNoPad, + /// Encode the string using [`base64::prelude::BASE64_URL_SAFE_NO_PAD`]. + /// # Errors + /// If the call to [`base64::engine::Engine::decode`] returns an error, that error is returned. + /// + /// If the call to [`String::from_utf8`] returns an error, that error is returned. + Base64DecodeUrlSafeNoPad, /// [`serde_json::Value::pointer`]. /// Does not do any string conversions. I should probably add an option for that. /// # Errors @@ -1111,8 +1127,12 @@ impl StringModification { Self::UrlDecode => *to=percent_decode_str(to).decode_utf8()?.into_owned(), Self::Base64EncodeStandard => *to = BASE64_STANDARD.encode(to.as_bytes()), Self::Base64DecodeStandard => *to = String::from_utf8(BASE64_STANDARD.decode(to.as_bytes())?)?, + Self::Base64EncodeStandardNoPad => *to = BASE64_STANDARD_NO_PAD.encode(to.as_bytes()), + Self::Base64DecodeStandardNoPad => *to = String::from_utf8(BASE64_STANDARD_NO_PAD.decode(to.as_bytes())?)?, Self::Base64EncodeUrlSafe => *to = BASE64_URL_SAFE.encode(to.as_bytes()), Self::Base64DecodeUrlSafe => *to = String::from_utf8(BASE64_URL_SAFE.decode(to.as_bytes())?)?, + Self::Base64EncodeUrlSafeNoPad => *to = BASE64_URL_SAFE_NO_PAD.encode(to.as_bytes()), + Self::Base64DecodeUrlSafeNoPad => *to = String::from_utf8(BASE64_URL_SAFE_NO_PAD.decode(to.as_bytes())?)?, Self::JsonPointer(pointer) => *to = serde_json::from_str::(to)?.pointer(get_str!(pointer, job_state, StringModificationError)).ok_or(StringModificationError::JsonValueNotFound)?.as_str().ok_or(StringModificationError::JsonValueIsNotAString)?.to_string(), // fixed_n is guaranteed to be in bounds. #[allow(clippy::indexing_slicing)] @@ -1183,8 +1203,10 @@ impl StringModification { Self::Debug(_) => false, Self::None | Self::Error | Self::Lowercase | Self::Uppercase | Self::Remove(_) | Self::KeepRange {..} | Self::UrlEncode | Self::UrlDecode | - Self::Base64EncodeStandard | Self::Base64DecodeStandard | Self::Base64EncodeUrlSafe | - Self::Base64DecodeUrlSafe => true, + Self::Base64EncodeStandard | Self::Base64DecodeStandard | + Self::Base64EncodeStandardNoPad | Self::Base64DecodeStandardNoPad | + Self::Base64EncodeUrlSafe | Self::Base64DecodeUrlSafe | + Self::Base64EncodeUrlSafeNoPad | Self::Base64DecodeUrlSafeNoPad => true, #[cfg(feature = "regex")] Self::RegexFind(_) => true }