changeset 52:ac13f3a4299a

Don't use an empty secret.
author Lewin Bormann <lbo@spheniscida.de>
date Thu, 03 Dec 2020 22:08:45 +0100
parents a75d164f028a
children 5dc62a1ae1ba
files src/main.rs
diffstat 1 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/main.rs	Thu Dec 03 22:00:25 2020 +0100
+++ b/src/main.rs	Thu Dec 03 22:08:45 2020 +0100
@@ -117,6 +117,13 @@
                 .into(),
         );
     }
+    // Length-limit notes.
+    if let Some(note) = note.as_ref() {
+        if note.len() > 4096 {
+            return http::bad_request("A note attached to a point may not be longer than 4 KiB.".into());
+        }
+    }
+
     let mut ts = chrono::Utc::now();
     if let Some(time) = time {
         ts = util::flexible_timestamp_parse(time).unwrap_or(ts);
@@ -132,13 +139,15 @@
     } else {
         note
     };
-
-    // Length-limit notes.
-    if let Some(note) = note.as_ref() {
-        if note.len() > 4096 {
-            return http::bad_request("A note attached to a point may not be longer than 4 KiB.".into());
+    let secret = if let Some(secret) = secret {
+        if secret.is_empty() {
+            None
+        } else {
+            Some(secret)
         }
-    }
+    } else {
+        secret
+    };
 
     let point = types::GeoPoint {
         lat: lat,