aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock27
-rw-r--r--Cargo.toml1
-rw-r--r--src/main.rs20
3 files changed, 5 insertions, 43 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 978714c..d090f28 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,15 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
-name = "aho-corasick"
-version = "0.7.18"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
-dependencies = [
- "memchr",
-]
-
-[[package]]
name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -222,7 +213,6 @@ dependencies = [
"home",
"hyper",
"hyper-rustls",
- "regex",
"serde_json",
"tokio",
"yup-oauth2",
@@ -617,23 +607,6 @@ dependencies = [
]
[[package]]
-name = "regex"
-version = "1.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
-dependencies = [
- "aho-corasick",
- "memchr",
- "regex-syntax",
-]
-
-[[package]]
-name = "regex-syntax"
-version = "0.6.25"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
-
-[[package]]
name = "ring"
version = "0.16.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index ab4ed89..9c4fc75 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,7 +10,6 @@ google-calendar3 = "2.0.4+20210327"
home = "0.5.3"
hyper = "0.14.7"
hyper-rustls = "0.22.1"
-regex = "1.5.4"
serde_json = "1.0.64"
tokio = { version = "1.6.0", features = ["rt-multi-thread"] }
yup-oauth2 = "5.1.0"
diff --git a/src/main.rs b/src/main.rs
index 9f4ad6a..a5e7a05 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,7 +4,6 @@ use google_calendar3::CalendarHub;
use home;
use hyper;
use hyper_rustls;
-use regex::Regex;
use tokio;
use yup_oauth2 as oauth2;
@@ -153,20 +152,11 @@ fn secret_from_file() -> oauth2::ApplicationSecret {
}
fn event_id_from_base64(event_id: &str) -> String {
- // Base64-matching regex from Xuanyuanzhiyuan
- // (https://stackoverflow.com/users/1076906/xuanyuanzhiyuan) on Stack
- // Overflow:
- // https://stackoverflow.com/questions/8571501/how-to-check-whether-a-string-is-base64-encoded-or-not/8571649#8571649
- let re = Regex::new(
- "^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$",
- ).unwrap();
-
- if !re.is_match(event_id) {
- return event_id.to_owned();
- }
-
- let decoded = &base64::decode(event_id).unwrap();
- let id_email_pair = str::from_utf8(decoded).unwrap();
+ let decoded = match base64::decode(event_id) {
+ Ok(d) => d,
+ Err(_) => return event_id.to_owned(),
+ };
+ let id_email_pair = str::from_utf8(&decoded).unwrap();
let values = id_email_pair.split(" ").collect::<Vec<_>>();
let id = values.first().unwrap().to_string();