You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2021/12/08 00:27:09 UTC

[incubator-ponymail-foal] 01/02: unshortenID should only unshorten short MIDs

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit 8eb39b3b064a73abe7d6f1b0c4172e554df3f66d
Author: Sebb <se...@apache.org>
AuthorDate: Wed Dec 8 00:22:19 2021 +0000

    unshortenID should only unshorten short MIDs
---
 webui/js/source/primer.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/webui/js/source/primer.js b/webui/js/source/primer.js
index 852bb2b..b058415 100644
--- a/webui/js/source/primer.js
+++ b/webui/js/source/primer.js
@@ -204,7 +204,9 @@ function unshortenID(mid) {
     // all short links begin with 'Z'. If not, it's not a short link
     // so let's just pass it through unaltered if so.
     // Some old shortlinks begin with 'B', so let's be backwards compatible for now.
-    if (mid[0] == 'Z' || mid[0] == 'B') {
+    // Shortlinks are also 15 chars (including prefix)
+    // They should also consist of base 36 chars or '-'
+    if ((mid[0] == 'Z' || mid[0] == 'B') && mid.length == 15){
         // remove padding
         let id1 = parseInt(mid.substr(1, 7).replace(/-/g, ""), 36)
         let id2 = parseInt(mid.substr(8, 7).replace(/-/g, ""), 36)