You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2019/03/03 16:51:12 UTC
[incubator-ponymail] 01/02: assign to a constant instead of
hardcoding inline, find a better func name
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail.git
commit d1b35b10a02c976ec1389d230aa573f9a040de48
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Sun Mar 3 17:50:46 2019 +0100
assign to a constant instead of hardcoding inline, find a better func name
---
site/js/dev/ponymail_assign_vars.js | 1 +
site/js/dev/ponymail_helperfuncs.js | 4 ++--
site/js/dev/ponymail_pagebuilder.js | 6 +++---
site/js/dev/ponymail_trends.js | 4 ++--
4 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/site/js/dev/ponymail_assign_vars.js b/site/js/dev/ponymail_assign_vars.js
index ef2df5e..1d03dcc 100644
--- a/site/js/dev/ponymail_assign_vars.js
+++ b/site/js/dev/ponymail_assign_vars.js
@@ -60,6 +60,7 @@ var pending_urls = {} // URL list for GetAsync's support functions (such as the
var pb_refresh = 0
var treeview_guard = {}
var mbox_month = null
+var INVALID_MAGIC_MARKER = "$INVALID"
var URL_BASE = pm_config.URLBase ? pm_config.URLBase.replace(/\/+/g, "/") : ""
diff --git a/site/js/dev/ponymail_helperfuncs.js b/site/js/dev/ponymail_helperfuncs.js
index b6ad259..7f38d44 100644
--- a/site/js/dev/ponymail_helperfuncs.js
+++ b/site/js/dev/ponymail_helperfuncs.js
@@ -177,9 +177,9 @@ function isArray(obj) {
// ML address: only accept valid mailing list IDs
-function sanitize_address(val) {
+function validate_address(val) {
var m = val.match(/^[-@A-Za-z.0-9]+$/);
- return m ? m[0] : "INVALID";
+ return m ? m[0] : INVALID_MAGIC_STRING;
}
// Check for slow URLs every 0.1 seconds
window.setInterval(checkForSlows, 100)
diff --git a/site/js/dev/ponymail_pagebuilder.js b/site/js/dev/ponymail_pagebuilder.js
index cda67ca..9a1d4bb 100644
--- a/site/js/dev/ponymail_pagebuilder.js
+++ b/site/js/dev/ponymail_pagebuilder.js
@@ -393,11 +393,11 @@ function getListInfo(list, xdomain, nopush) {
xdomain = list.replace(/^.*?@/, "")
}
- if (list) list = sanitize_address(list);
- if (xdomain) xdomain = sanitize_address(xdomain);
+ if (list) list = validate_address(list);
+ if (xdomain) xdomain = validate_address(xdomain);
// If invalid address passed, complain and exit - no need to attempt fetching stats
- if (list == 'INVALID' || xdomain == 'INVALID') {
+ if (list == INVALID_MAGIC_STRING || xdomain == INVALID_MAGIC_STRING) {
alert("Invalid mailing list address supplied!");
return
}
diff --git a/site/js/dev/ponymail_trends.js b/site/js/dev/ponymail_trends.js
index eeec976..7de7668 100644
--- a/site/js/dev/ponymail_trends.js
+++ b/site/js/dev/ponymail_trends.js
@@ -287,8 +287,8 @@ function gatherTrends() {
var dspan = a_arr[1]
var query = a_arr[2]
- list = sanitize_address(list);
- if (list == 'INVALID') {
+ list = validate_address(list);
+ if (list == INVALID_MAGIC_STRING) {
alert("Invalid mailing list address supplied!");
return
}