add-to-calendar-button 2.6.20 → 2.6.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/css/atcb-3d.css +1 -1
- package/assets/css/atcb-date.css +1 -1
- package/assets/css/atcb-flat.css +1 -1
- package/assets/css/atcb-neumorphism.css +1 -1
- package/assets/css/atcb-round.css +1 -1
- package/assets/css/atcb-text.css +1 -1
- package/assets/css/atcb.css +1 -1
- package/dist/atcb-no-pro-unstyle.js +31 -34
- package/dist/atcb-no-pro.js +31 -34
- package/dist/atcb-unstyle.js +31 -34
- package/dist/atcb.js +31 -34
- package/dist/commonjs/index.js +31 -35
- package/dist/commonjs/no-pro/index.js +31 -35
- package/dist/commonjs/no-pro-unstyle/index.js +31 -35
- package/dist/commonjs/unstyle/index.js +31 -35
- package/dist/module/index.js +31 -34
- package/dist/module/no-pro/index.js +31 -34
- package/dist/module/no-pro-unstyle/index.js +31 -34
- package/dist/module/unstyle/index.js +31 -34
- package/package.json +7 -8
- package/test/server-side-init.test.js +0 -3
- package/test/test-prep.js +0 -4
- package/test/wc-tests/wc-load.test.js +0 -3
- package/.eslintrc.json +0 -36
- package/dist/commonjs/.eslintrc.json +0 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
2
1
|
const tzlibActions = require('timezones-ical-library');
|
|
3
2
|
/*!
|
|
4
3
|
* @preserve
|
|
@@ -7,14 +6,14 @@ const tzlibActions = require('timezones-ical-library');
|
|
|
7
6
|
* Add to Calendar Button
|
|
8
7
|
* ++++++++++++++++++++++
|
|
9
8
|
*
|
|
10
|
-
* Version: 2.6.
|
|
9
|
+
* Version: 2.6.21
|
|
11
10
|
* Creator: Jens Kuerschner (https://jekuer.com)
|
|
12
11
|
* Project: https://github.com/add2cal/add-to-calendar-button
|
|
13
12
|
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
|
|
14
13
|
* Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
|
|
15
14
|
*
|
|
16
15
|
*/
|
|
17
|
-
const atcbVersion = '2.6.
|
|
16
|
+
const atcbVersion = '2.6.21';
|
|
18
17
|
const atcbCssTemplate = {};
|
|
19
18
|
const atcbIsBrowser = () => {
|
|
20
19
|
if (typeof window === 'undefined') {
|
|
@@ -58,7 +57,7 @@ const atcbIsAndroid = atcbIsBrowser()
|
|
|
58
57
|
};*/
|
|
59
58
|
const atcbIsSafari = atcbIsBrowser()
|
|
60
59
|
? () => {
|
|
61
|
-
if (/^((?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent)) {
|
|
60
|
+
if (/^(?:(?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent)) {
|
|
62
61
|
return true;
|
|
63
62
|
} else {
|
|
64
63
|
return false;
|
|
@@ -76,7 +75,7 @@ const atcbIsMobile = () => {
|
|
|
76
75
|
};
|
|
77
76
|
const atcbIsWebView = atcbIsBrowser()
|
|
78
77
|
? () => {
|
|
79
|
-
if (
|
|
78
|
+
if (/; ?wv|(?:iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent)) {
|
|
80
79
|
return true;
|
|
81
80
|
} else {
|
|
82
81
|
return false;
|
|
@@ -87,7 +86,7 @@ const atcbIsWebView = atcbIsBrowser()
|
|
|
87
86
|
};
|
|
88
87
|
const atcbIsProblematicWebView = atcbIsBrowser()
|
|
89
88
|
? () => {
|
|
90
|
-
if (/
|
|
89
|
+
if (/Instagram/i.test(navigator.userAgent)) {
|
|
91
90
|
return true;
|
|
92
91
|
} else {
|
|
93
92
|
return false;
|
|
@@ -306,7 +305,7 @@ function atcb_decorate_data_timezone(tz = null) {
|
|
|
306
305
|
function atcb_decorate_data_rrule(data) {
|
|
307
306
|
if (data.recurrence && data.recurrence !== '') {
|
|
308
307
|
data.recurrence = data.recurrence.replace(/\s+/g, '').toUpperCase();
|
|
309
|
-
if (!/^(RRULE:[\w
|
|
308
|
+
if (!/^(?:RRULE:[\w=;,:+\-/\\]+|daily|weekly|monthly|yearly)$/im.test(data.recurrence)) {
|
|
310
309
|
data.recurrence = '!wrong rrule format!';
|
|
311
310
|
} else {
|
|
312
311
|
if (/^RRULE:/i.test(data.recurrence)) {
|
|
@@ -549,8 +548,7 @@ function atcb_decorate_data_description(data, i) {
|
|
|
549
548
|
description = cleanDescription(description);
|
|
550
549
|
if (data.customVar) {
|
|
551
550
|
for (const key in data.customVar) {
|
|
552
|
-
const sanitizedKey = key.replace(/[
|
|
553
|
-
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
551
|
+
const sanitizedKey = key.replace(/[^\w\-.]/g, '');
|
|
554
552
|
description = description.replace(new RegExp(`%%${sanitizedKey}%%`, 'g'), data.customVar[`${key}`]);
|
|
555
553
|
}
|
|
556
554
|
}
|
|
@@ -609,10 +607,8 @@ function atcb_decorate_data_extend(data) {
|
|
|
609
607
|
}
|
|
610
608
|
if (data.customVar) {
|
|
611
609
|
for (const key in data.customVar) {
|
|
612
|
-
const sanitizedKey = key.replace(/[
|
|
613
|
-
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
610
|
+
const sanitizedKey = key.replace(/[^\w\-.]/g, '');
|
|
614
611
|
data.dates[`${i}`].name = data.dates[`${i}`].name.replace(new RegExp(`%%${sanitizedKey}%%`, 'g'), data.customVar[`${key}`]);
|
|
615
|
-
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
616
612
|
data.dates[`${i}`].location = data.dates[`${i}`].location.replace(new RegExp(`%%${sanitizedKey}%%`, 'g'), data.customVar[`${key}`]);
|
|
617
613
|
}
|
|
618
614
|
}
|
|
@@ -631,7 +627,7 @@ function atcb_date_cleanup(dateTimeData) {
|
|
|
631
627
|
}
|
|
632
628
|
const endpoints = ['start', 'end'];
|
|
633
629
|
endpoints.forEach(function (point) {
|
|
634
|
-
if (!/^(
|
|
630
|
+
if (!/^(?:\d{4}-\d{2}-\d{2}T?(?:\d{2}:\d{2})?Z?|today(?:\+\d{1,4})?)$/i.test(dateTimeData[point + 'Date'])) {
|
|
635
631
|
dateTimeData[point + 'Date'] = 'badly-formed';
|
|
636
632
|
} else {
|
|
637
633
|
dateTimeData[point + 'Date'] = atcb_date_calculation(dateTimeData[point + 'Date']);
|
|
@@ -836,7 +832,7 @@ async function atcb_validate_buttonStyle(data, msgPrefix) {
|
|
|
836
832
|
if (!availableStyles.includes(data.buttonStyle)) {
|
|
837
833
|
throw new Error(msgPrefix + ' failed: provided buttonStyle invalid');
|
|
838
834
|
}
|
|
839
|
-
if (data.customCss && data.customCss !== '' && (!atcb_secure_url(data.customCss, false) || !/\.css(
|
|
835
|
+
if (data.customCss && data.customCss !== '' && (!atcb_secure_url(data.customCss, false) || !/\.css(?:$|\?)/.test(data.customCss))) {
|
|
840
836
|
throw new Error(msgPrefix + ' failed: customCss provided, but no valid url');
|
|
841
837
|
}
|
|
842
838
|
if ((!data.customCss || data.customCss === '') && data.buttonStyle === 'custom') {
|
|
@@ -937,7 +933,7 @@ async function atcb_validate_attendee(data, msgPrefix, i, msgSuffix) {
|
|
|
937
933
|
return true;
|
|
938
934
|
}
|
|
939
935
|
async function atcb_validate_uid(data, msgPrefix, i, msgSuffix) {
|
|
940
|
-
if (!/^(
|
|
936
|
+
if (!/^(?:\w|-){1,254}$/.test(data.dates[`${i}`].uid)) {
|
|
941
937
|
if (data.debug) {
|
|
942
938
|
console.warn(msgPrefix + ': UID not valid. May only contain alpha, digits, and dashes; and be less than 255 characters. Falling back to an automated value!' + msgSuffix);
|
|
943
939
|
}
|
|
@@ -1006,7 +1002,7 @@ async function atcb_validate_rrule(data, msgPrefix) {
|
|
|
1006
1002
|
if (data.recurrence && data.recurrence !== '' && data.dates.length > 1) {
|
|
1007
1003
|
throw new Error(msgPrefix + ' failed: RRULE and multi-date set at the same time');
|
|
1008
1004
|
}
|
|
1009
|
-
if (data.recurrence && data.recurrence !== '' && !/^RRULE:[\w
|
|
1005
|
+
if (data.recurrence && data.recurrence !== '' && !/^RRULE:[\w=;,:+\-/\\]+$/i.test(data.recurrence)) {
|
|
1010
1006
|
throw new Error(msgPrefix + ' failed: RRULE data misspelled');
|
|
1011
1007
|
}
|
|
1012
1008
|
return true;
|
|
@@ -1015,22 +1011,22 @@ async function atcb_validate_rrule_simplyfied(data, msgPrefix) {
|
|
|
1015
1011
|
if (data.recurrence_interval && (data.recurrence_interval < 1 || data.recurrence_interval % 1 !== 0)) {
|
|
1016
1012
|
throw new Error(msgPrefix + ' failed: recurrence data (interval) misspelled');
|
|
1017
1013
|
}
|
|
1018
|
-
if (data.recurrence_until && data.recurrence_until !== '' && !/^
|
|
1014
|
+
if (data.recurrence_until && data.recurrence_until !== '' && !/^[\d\-:]+$/.test(data.recurrence_until)) {
|
|
1019
1015
|
throw new Error(msgPrefix + ' failed: recurrence data (until) misspelled');
|
|
1020
1016
|
}
|
|
1021
1017
|
if (data.recurrence_count && (data.recurrence_count < 1 || data.recurrence_count % 1 !== 0)) {
|
|
1022
1018
|
throw new Error(msgPrefix + ' failed: recurrence data (interval) misspelled');
|
|
1023
1019
|
}
|
|
1024
|
-
if (data.recurrence_byMonth && data.recurrence_byMonth !== '' && !/^
|
|
1020
|
+
if (data.recurrence_byMonth && data.recurrence_byMonth !== '' && !/^[\d,]+$/.test(data.recurrence_byMonth)) {
|
|
1025
1021
|
throw new Error(msgPrefix + ' failed: recurrence data (byMonth) misspelled');
|
|
1026
1022
|
}
|
|
1027
|
-
if (data.recurrence_byMonthDay && data.recurrence_byMonthDay !== '' && !/^
|
|
1023
|
+
if (data.recurrence_byMonthDay && data.recurrence_byMonthDay !== '' && !/^[\d,]+$/.test(data.recurrence_byMonthDay)) {
|
|
1028
1024
|
throw new Error(msgPrefix + ' failed: recurrence data (byMonthDay) misspelled');
|
|
1029
1025
|
}
|
|
1030
|
-
if (data.recurrence_byDay && data.recurrence_byDay !== '' && !/^(\d
|
|
1026
|
+
if (data.recurrence_byDay && data.recurrence_byDay !== '' && !/^(?:[\d,-]|MO|TU|WE|TH|FR|SA|SU)+$/im.test(data.recurrence_byDay)) {
|
|
1031
1027
|
throw new Error(msgPrefix + ' failed: recurrence data (byDay) misspelled');
|
|
1032
1028
|
}
|
|
1033
|
-
if (data.recurrence_weekstart && data.recurrence_weekstart !== '' && !/^(MO|TU|WE|TH|FR|SA|SU)$/im.test(data.recurrence_weekstart)) {
|
|
1029
|
+
if (data.recurrence_weekstart && data.recurrence_weekstart !== '' && !/^(?:MO|TU|WE|TH|FR|SA|SU)$/im.test(data.recurrence_weekstart)) {
|
|
1034
1030
|
throw new Error(msgPrefix + ' failed: recurrence data (weekstart) misspelled');
|
|
1035
1031
|
}
|
|
1036
1032
|
return true;
|
|
@@ -1541,7 +1537,8 @@ function atcb_create_atcbl(host, atList = true, returnEl = false, licenseNoteOnl
|
|
|
1541
1537
|
}
|
|
1542
1538
|
} else {
|
|
1543
1539
|
atcbL.innerHTML = 'Using the <a href="https://add-to-calendar-pro.com" target="_blank" rel="noopener referrer">Add to Calendar Button</a>, licensed under the Elastic License 2.0 (ELv2).';
|
|
1544
|
-
atcbL.setAttribute('style', 'none !important');
|
|
1540
|
+
atcbL.setAttribute('style', 'display:none !important');
|
|
1541
|
+
atcbL.classList.add('atcb-attribution');
|
|
1545
1542
|
host.append(atcbL);
|
|
1546
1543
|
}
|
|
1547
1544
|
if (returnEl) return null;
|
|
@@ -2218,7 +2215,7 @@ function atcb_subscribe_ical(data, fileUrl) {
|
|
|
2218
2215
|
function atcb_subscribe_google(data, fileUrl) {
|
|
2219
2216
|
const baseUrl = 'https://calendar.google.com/calendar/r?cid=';
|
|
2220
2217
|
const baseUrlApp = 'calendar.google.com/calendar?cid=';
|
|
2221
|
-
const fileUrlRegex = /^(https?:\/\/|webcal:\/\/|\/\/)calendar\.google\.com\//;
|
|
2218
|
+
const fileUrlRegex = /^(?:https?:\/\/|webcal:\/\/|\/\/)calendar\.google\.com\//;
|
|
2222
2219
|
const newFileUrl = (function () {
|
|
2223
2220
|
if (fileUrlRegex.test(fileUrl)) {
|
|
2224
2221
|
return fileUrl.replace(/^(.)*\?cid=/, '');
|
|
@@ -2253,7 +2250,7 @@ function atcb_generate_google(data, date, subEvent = 'all') {
|
|
|
2253
2250
|
urlParts.push('https://calendar.google.com/calendar/render?action=TEMPLATE');
|
|
2254
2251
|
const formattedDate = atcb_generate_time(date, 'clean', 'google');
|
|
2255
2252
|
urlParts.push('dates=' + encodeURIComponent(formattedDate.start) + '%2F' + encodeURIComponent(formattedDate.end));
|
|
2256
|
-
if (date.timeZone && date.timeZone !== '' && !/
|
|
2253
|
+
if (date.timeZone && date.timeZone !== '' && !/GMT[+|-]\d{1,2}|Etc\/U|Etc\/Zulu|CET|CST6CDT|EET|EST|MET|MST|PST8PDT|WET/i.test(date.timeZone) && !formattedDate.allday) {
|
|
2257
2254
|
urlParts.push('ctz=' + date.timeZone);
|
|
2258
2255
|
}
|
|
2259
2256
|
if (date.name && date.name !== '') {
|
|
@@ -2404,7 +2401,6 @@ function atcb_open_cal_url(data, type, url, subscribe = false, subEvent = null,
|
|
|
2404
2401
|
return;
|
|
2405
2402
|
}
|
|
2406
2403
|
}
|
|
2407
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
2408
2404
|
const newTab = window.open(url, target);
|
|
2409
2405
|
if (newTab) {
|
|
2410
2406
|
newTab.focus();
|
|
@@ -2626,7 +2622,7 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', a
|
|
|
2626
2622
|
}
|
|
2627
2623
|
return durationHours + ':' + ('0' + durationMinutes).slice(-2);
|
|
2628
2624
|
})();
|
|
2629
|
-
if (targetCal == 'ical' || (targetCal == 'google' && !/
|
|
2625
|
+
if (targetCal == 'ical' || (targetCal == 'google' && !/GMT[+|-]\d{1,2}|Etc\/U|Etc\/Zulu|CET|CST6CDT|EET|EST|MET|MST|PST8PDT|WET/i.test(data.timeZone))) {
|
|
2630
2626
|
return {
|
|
2631
2627
|
start: atcb_format_datetime(newStartDate, 'clean', true, true),
|
|
2632
2628
|
end: atcb_format_datetime(newEndDate, 'clean', true, true),
|
|
@@ -2948,7 +2944,7 @@ function atcb_secure_url(url, throwError = true) {
|
|
|
2948
2944
|
}
|
|
2949
2945
|
}
|
|
2950
2946
|
function atcb_validEmail(email) {
|
|
2951
|
-
if (!/^.{0,70}@.{1,30}\.[a-
|
|
2947
|
+
if (!/^.{0,70}@.{1,30}\.[a-z]{2,9}$/i.test(email)) {
|
|
2952
2948
|
return false;
|
|
2953
2949
|
}
|
|
2954
2950
|
return true;
|
|
@@ -2966,9 +2962,9 @@ function atcb_rewrite_html_elements(content, clear = false, iCalBreaks = false)
|
|
|
2966
2962
|
content = content.replace(/\{url\}(.+?)\{\/url\}/gi, (match, p1) => {
|
|
2967
2963
|
return p1.split('|')[0];
|
|
2968
2964
|
});
|
|
2969
|
-
content = content.replace(/\[(
|
|
2970
|
-
content = content.replace(/\{(
|
|
2971
|
-
content = content.replace(/&[#a-
|
|
2965
|
+
content = content.replace(/\[\/?(hr|[pbui]|strong|em|li|ul|ol|h\d)\]/gi, '');
|
|
2966
|
+
content = content.replace(/\{\/?(hr|[pbui]|strong|em|li|ul|ol|h\d)\}/gi, '');
|
|
2967
|
+
content = content.replace(/&[#a-z0-9]{1,9};/gi, '');
|
|
2972
2968
|
} else {
|
|
2973
2969
|
content = content.replace(/\[url\]((?:(?!\[\/url\]).)*)\[\/url\]/gi, function (match, p1) {
|
|
2974
2970
|
return atcb_parse_url_code(p1);
|
|
@@ -2976,8 +2972,8 @@ function atcb_rewrite_html_elements(content, clear = false, iCalBreaks = false)
|
|
|
2976
2972
|
content = content.replace(/\{url\}((?:(?!\[\/url\]).)*)\{\/url\}/gi, function (match, p1) {
|
|
2977
2973
|
return atcb_parse_url_code(p1);
|
|
2978
2974
|
});
|
|
2979
|
-
content = content.replace(/\[(
|
|
2980
|
-
content = content.replace(/\{(
|
|
2975
|
+
content = content.replace(/\[(\/)?(br|hr|[pbui]|strong|em|li|ul|ol|h\d)(\s?\/?)\]/gi, '<$1$2$3>');
|
|
2976
|
+
content = content.replace(/\{(\/)?(br|hr|[pbui]|strong|em|li|ul|ol|h\d)(\s?\/?)\}/gi, '<$1$2$3>');
|
|
2981
2977
|
}
|
|
2982
2978
|
return content;
|
|
2983
2979
|
}
|
|
@@ -4187,7 +4183,7 @@ if (atcbIsBrowser()) {
|
|
|
4187
4183
|
this.data.identifier = this.identifier;
|
|
4188
4184
|
} else {
|
|
4189
4185
|
if (this.data.identifier && this.data.identifier !== '') {
|
|
4190
|
-
if (!/^[\w
|
|
4186
|
+
if (!/^[\w-]+$/.test(this.data.identifier)) {
|
|
4191
4187
|
this.data.identifier = '';
|
|
4192
4188
|
if (this.debug) {
|
|
4193
4189
|
let prefix = 'Add to Calendar Button';
|
|
@@ -4385,7 +4381,7 @@ async function atcb_load_css(host, rootObj = null, data) {
|
|
|
4385
4381
|
const cssGlobalContent = document.createElement('style');
|
|
4386
4382
|
cssGlobalContent.id = 'atcb-global-style';
|
|
4387
4383
|
const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
4388
|
-
cssGlobalContent.innerText = '.atcb-modal-no-scroll{overflow-y:hidden !important;-webkit-overflow-scrolling:touch;} body.atcb-modal-no-scroll{padding-right:' + scrollBarWidth + 'px;}';
|
|
4384
|
+
cssGlobalContent.innerText = '.atcb-modal-no-scroll{overflow-y:hidden !important;-webkit-overflow-scrolling:touch;} body.atcb-modal-no-scroll{padding-right:' + scrollBarWidth + 'px;}.atcb-attribution{display:none;}';
|
|
4389
4385
|
if (nonceVal) {
|
|
4390
4386
|
cssGlobalContent.setAttribute('nonce', nonceVal);
|
|
4391
4387
|
}
|
|
@@ -4534,7 +4530,7 @@ async function atcb_action(inputData, triggerElement, keyboardTrigger = false) {
|
|
|
4534
4530
|
if (triggerElement.id && triggerElement.id !== '') {
|
|
4535
4531
|
data.identifier = triggerElement.id;
|
|
4536
4532
|
} else {
|
|
4537
|
-
if (data.identifier && data.identifier != '' && /^[\w
|
|
4533
|
+
if (data.identifier && data.identifier != '' && /^[\w-]+$/.test(data.identifier)) {
|
|
4538
4534
|
data.identifier = 'atcb-btn-' + data.identifier;
|
|
4539
4535
|
} else {
|
|
4540
4536
|
data.identifier = 'atcb-btn-custom';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
2
1
|
const tzlibActions = require('timezones-ical-library');
|
|
3
2
|
/*!
|
|
4
3
|
* @preserve
|
|
@@ -7,14 +6,14 @@ const tzlibActions = require('timezones-ical-library');
|
|
|
7
6
|
* Add to Calendar Button
|
|
8
7
|
* ++++++++++++++++++++++
|
|
9
8
|
*
|
|
10
|
-
* Version: 2.6.
|
|
9
|
+
* Version: 2.6.21
|
|
11
10
|
* Creator: Jens Kuerschner (https://jekuer.com)
|
|
12
11
|
* Project: https://github.com/add2cal/add-to-calendar-button
|
|
13
12
|
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
|
|
14
13
|
* Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
|
|
15
14
|
*
|
|
16
15
|
*/
|
|
17
|
-
const atcbVersion = '2.6.
|
|
16
|
+
const atcbVersion = '2.6.21';
|
|
18
17
|
const atcbCssTemplate = {};
|
|
19
18
|
const atcbIsBrowser = () => {
|
|
20
19
|
if (typeof window === 'undefined') {
|
|
@@ -58,7 +57,7 @@ const atcbIsAndroid = atcbIsBrowser()
|
|
|
58
57
|
};*/
|
|
59
58
|
const atcbIsSafari = atcbIsBrowser()
|
|
60
59
|
? () => {
|
|
61
|
-
if (/^((?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent)) {
|
|
60
|
+
if (/^(?:(?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent)) {
|
|
62
61
|
return true;
|
|
63
62
|
} else {
|
|
64
63
|
return false;
|
|
@@ -76,7 +75,7 @@ const atcbIsMobile = () => {
|
|
|
76
75
|
};
|
|
77
76
|
const atcbIsWebView = atcbIsBrowser()
|
|
78
77
|
? () => {
|
|
79
|
-
if (
|
|
78
|
+
if (/; ?wv|(?:iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent)) {
|
|
80
79
|
return true;
|
|
81
80
|
} else {
|
|
82
81
|
return false;
|
|
@@ -87,7 +86,7 @@ const atcbIsWebView = atcbIsBrowser()
|
|
|
87
86
|
};
|
|
88
87
|
const atcbIsProblematicWebView = atcbIsBrowser()
|
|
89
88
|
? () => {
|
|
90
|
-
if (/
|
|
89
|
+
if (/Instagram/i.test(navigator.userAgent)) {
|
|
91
90
|
return true;
|
|
92
91
|
} else {
|
|
93
92
|
return false;
|
|
@@ -306,7 +305,7 @@ function atcb_decorate_data_timezone(tz = null) {
|
|
|
306
305
|
function atcb_decorate_data_rrule(data) {
|
|
307
306
|
if (data.recurrence && data.recurrence !== '') {
|
|
308
307
|
data.recurrence = data.recurrence.replace(/\s+/g, '').toUpperCase();
|
|
309
|
-
if (!/^(RRULE:[\w
|
|
308
|
+
if (!/^(?:RRULE:[\w=;,:+\-/\\]+|daily|weekly|monthly|yearly)$/im.test(data.recurrence)) {
|
|
310
309
|
data.recurrence = '!wrong rrule format!';
|
|
311
310
|
} else {
|
|
312
311
|
if (/^RRULE:/i.test(data.recurrence)) {
|
|
@@ -549,8 +548,7 @@ function atcb_decorate_data_description(data, i) {
|
|
|
549
548
|
description = cleanDescription(description);
|
|
550
549
|
if (data.customVar) {
|
|
551
550
|
for (const key in data.customVar) {
|
|
552
|
-
const sanitizedKey = key.replace(/[
|
|
553
|
-
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
551
|
+
const sanitizedKey = key.replace(/[^\w\-.]/g, '');
|
|
554
552
|
description = description.replace(new RegExp(`%%${sanitizedKey}%%`, 'g'), data.customVar[`${key}`]);
|
|
555
553
|
}
|
|
556
554
|
}
|
|
@@ -609,10 +607,8 @@ function atcb_decorate_data_extend(data) {
|
|
|
609
607
|
}
|
|
610
608
|
if (data.customVar) {
|
|
611
609
|
for (const key in data.customVar) {
|
|
612
|
-
const sanitizedKey = key.replace(/[
|
|
613
|
-
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
610
|
+
const sanitizedKey = key.replace(/[^\w\-.]/g, '');
|
|
614
611
|
data.dates[`${i}`].name = data.dates[`${i}`].name.replace(new RegExp(`%%${sanitizedKey}%%`, 'g'), data.customVar[`${key}`]);
|
|
615
|
-
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
616
612
|
data.dates[`${i}`].location = data.dates[`${i}`].location.replace(new RegExp(`%%${sanitizedKey}%%`, 'g'), data.customVar[`${key}`]);
|
|
617
613
|
}
|
|
618
614
|
}
|
|
@@ -631,7 +627,7 @@ function atcb_date_cleanup(dateTimeData) {
|
|
|
631
627
|
}
|
|
632
628
|
const endpoints = ['start', 'end'];
|
|
633
629
|
endpoints.forEach(function (point) {
|
|
634
|
-
if (!/^(
|
|
630
|
+
if (!/^(?:\d{4}-\d{2}-\d{2}T?(?:\d{2}:\d{2})?Z?|today(?:\+\d{1,4})?)$/i.test(dateTimeData[point + 'Date'])) {
|
|
635
631
|
dateTimeData[point + 'Date'] = 'badly-formed';
|
|
636
632
|
} else {
|
|
637
633
|
dateTimeData[point + 'Date'] = atcb_date_calculation(dateTimeData[point + 'Date']);
|
|
@@ -836,7 +832,7 @@ async function atcb_validate_buttonStyle(data, msgPrefix) {
|
|
|
836
832
|
if (!availableStyles.includes(data.buttonStyle)) {
|
|
837
833
|
throw new Error(msgPrefix + ' failed: provided buttonStyle invalid');
|
|
838
834
|
}
|
|
839
|
-
if (data.customCss && data.customCss !== '' && (!atcb_secure_url(data.customCss, false) || !/\.css(
|
|
835
|
+
if (data.customCss && data.customCss !== '' && (!atcb_secure_url(data.customCss, false) || !/\.css(?:$|\?)/.test(data.customCss))) {
|
|
840
836
|
throw new Error(msgPrefix + ' failed: customCss provided, but no valid url');
|
|
841
837
|
}
|
|
842
838
|
if ((!data.customCss || data.customCss === '') && data.buttonStyle === 'custom') {
|
|
@@ -937,7 +933,7 @@ async function atcb_validate_attendee(data, msgPrefix, i, msgSuffix) {
|
|
|
937
933
|
return true;
|
|
938
934
|
}
|
|
939
935
|
async function atcb_validate_uid(data, msgPrefix, i, msgSuffix) {
|
|
940
|
-
if (!/^(
|
|
936
|
+
if (!/^(?:\w|-){1,254}$/.test(data.dates[`${i}`].uid)) {
|
|
941
937
|
if (data.debug) {
|
|
942
938
|
console.warn(msgPrefix + ': UID not valid. May only contain alpha, digits, and dashes; and be less than 255 characters. Falling back to an automated value!' + msgSuffix);
|
|
943
939
|
}
|
|
@@ -1006,7 +1002,7 @@ async function atcb_validate_rrule(data, msgPrefix) {
|
|
|
1006
1002
|
if (data.recurrence && data.recurrence !== '' && data.dates.length > 1) {
|
|
1007
1003
|
throw new Error(msgPrefix + ' failed: RRULE and multi-date set at the same time');
|
|
1008
1004
|
}
|
|
1009
|
-
if (data.recurrence && data.recurrence !== '' && !/^RRULE:[\w
|
|
1005
|
+
if (data.recurrence && data.recurrence !== '' && !/^RRULE:[\w=;,:+\-/\\]+$/i.test(data.recurrence)) {
|
|
1010
1006
|
throw new Error(msgPrefix + ' failed: RRULE data misspelled');
|
|
1011
1007
|
}
|
|
1012
1008
|
return true;
|
|
@@ -1015,22 +1011,22 @@ async function atcb_validate_rrule_simplyfied(data, msgPrefix) {
|
|
|
1015
1011
|
if (data.recurrence_interval && (data.recurrence_interval < 1 || data.recurrence_interval % 1 !== 0)) {
|
|
1016
1012
|
throw new Error(msgPrefix + ' failed: recurrence data (interval) misspelled');
|
|
1017
1013
|
}
|
|
1018
|
-
if (data.recurrence_until && data.recurrence_until !== '' && !/^
|
|
1014
|
+
if (data.recurrence_until && data.recurrence_until !== '' && !/^[\d\-:]+$/.test(data.recurrence_until)) {
|
|
1019
1015
|
throw new Error(msgPrefix + ' failed: recurrence data (until) misspelled');
|
|
1020
1016
|
}
|
|
1021
1017
|
if (data.recurrence_count && (data.recurrence_count < 1 || data.recurrence_count % 1 !== 0)) {
|
|
1022
1018
|
throw new Error(msgPrefix + ' failed: recurrence data (interval) misspelled');
|
|
1023
1019
|
}
|
|
1024
|
-
if (data.recurrence_byMonth && data.recurrence_byMonth !== '' && !/^
|
|
1020
|
+
if (data.recurrence_byMonth && data.recurrence_byMonth !== '' && !/^[\d,]+$/.test(data.recurrence_byMonth)) {
|
|
1025
1021
|
throw new Error(msgPrefix + ' failed: recurrence data (byMonth) misspelled');
|
|
1026
1022
|
}
|
|
1027
|
-
if (data.recurrence_byMonthDay && data.recurrence_byMonthDay !== '' && !/^
|
|
1023
|
+
if (data.recurrence_byMonthDay && data.recurrence_byMonthDay !== '' && !/^[\d,]+$/.test(data.recurrence_byMonthDay)) {
|
|
1028
1024
|
throw new Error(msgPrefix + ' failed: recurrence data (byMonthDay) misspelled');
|
|
1029
1025
|
}
|
|
1030
|
-
if (data.recurrence_byDay && data.recurrence_byDay !== '' && !/^(\d
|
|
1026
|
+
if (data.recurrence_byDay && data.recurrence_byDay !== '' && !/^(?:[\d,-]|MO|TU|WE|TH|FR|SA|SU)+$/im.test(data.recurrence_byDay)) {
|
|
1031
1027
|
throw new Error(msgPrefix + ' failed: recurrence data (byDay) misspelled');
|
|
1032
1028
|
}
|
|
1033
|
-
if (data.recurrence_weekstart && data.recurrence_weekstart !== '' && !/^(MO|TU|WE|TH|FR|SA|SU)$/im.test(data.recurrence_weekstart)) {
|
|
1029
|
+
if (data.recurrence_weekstart && data.recurrence_weekstart !== '' && !/^(?:MO|TU|WE|TH|FR|SA|SU)$/im.test(data.recurrence_weekstart)) {
|
|
1034
1030
|
throw new Error(msgPrefix + ' failed: recurrence data (weekstart) misspelled');
|
|
1035
1031
|
}
|
|
1036
1032
|
return true;
|
|
@@ -2262,7 +2258,8 @@ function atcb_create_atcbl(host, atList = true, returnEl = false, licenseNoteOnl
|
|
|
2262
2258
|
}
|
|
2263
2259
|
} else {
|
|
2264
2260
|
atcbL.innerHTML = 'Using the <a href="https://add-to-calendar-pro.com" target="_blank" rel="noopener referrer">Add to Calendar Button</a>, licensed under the Elastic License 2.0 (ELv2).';
|
|
2265
|
-
atcbL.setAttribute('style', 'none !important');
|
|
2261
|
+
atcbL.setAttribute('style', 'display:none !important');
|
|
2262
|
+
atcbL.classList.add('atcb-attribution');
|
|
2266
2263
|
host.append(atcbL);
|
|
2267
2264
|
}
|
|
2268
2265
|
if (returnEl) return null;
|
|
@@ -2939,7 +2936,7 @@ function atcb_subscribe_ical(data, fileUrl) {
|
|
|
2939
2936
|
function atcb_subscribe_google(data, fileUrl) {
|
|
2940
2937
|
const baseUrl = 'https://calendar.google.com/calendar/r?cid=';
|
|
2941
2938
|
const baseUrlApp = 'calendar.google.com/calendar?cid=';
|
|
2942
|
-
const fileUrlRegex = /^(https?:\/\/|webcal:\/\/|\/\/)calendar\.google\.com\//;
|
|
2939
|
+
const fileUrlRegex = /^(?:https?:\/\/|webcal:\/\/|\/\/)calendar\.google\.com\//;
|
|
2943
2940
|
const newFileUrl = (function () {
|
|
2944
2941
|
if (fileUrlRegex.test(fileUrl)) {
|
|
2945
2942
|
return fileUrl.replace(/^(.)*\?cid=/, '');
|
|
@@ -2974,7 +2971,7 @@ function atcb_generate_google(data, date, subEvent = 'all') {
|
|
|
2974
2971
|
urlParts.push('https://calendar.google.com/calendar/render?action=TEMPLATE');
|
|
2975
2972
|
const formattedDate = atcb_generate_time(date, 'clean', 'google');
|
|
2976
2973
|
urlParts.push('dates=' + encodeURIComponent(formattedDate.start) + '%2F' + encodeURIComponent(formattedDate.end));
|
|
2977
|
-
if (date.timeZone && date.timeZone !== '' && !/
|
|
2974
|
+
if (date.timeZone && date.timeZone !== '' && !/GMT[+|-]\d{1,2}|Etc\/U|Etc\/Zulu|CET|CST6CDT|EET|EST|MET|MST|PST8PDT|WET/i.test(date.timeZone) && !formattedDate.allday) {
|
|
2978
2975
|
urlParts.push('ctz=' + date.timeZone);
|
|
2979
2976
|
}
|
|
2980
2977
|
if (date.name && date.name !== '') {
|
|
@@ -3125,7 +3122,6 @@ function atcb_open_cal_url(data, type, url, subscribe = false, subEvent = null,
|
|
|
3125
3122
|
return;
|
|
3126
3123
|
}
|
|
3127
3124
|
}
|
|
3128
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
3129
3125
|
const newTab = window.open(url, target);
|
|
3130
3126
|
if (newTab) {
|
|
3131
3127
|
newTab.focus();
|
|
@@ -3347,7 +3343,7 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', a
|
|
|
3347
3343
|
}
|
|
3348
3344
|
return durationHours + ':' + ('0' + durationMinutes).slice(-2);
|
|
3349
3345
|
})();
|
|
3350
|
-
if (targetCal == 'ical' || (targetCal == 'google' && !/
|
|
3346
|
+
if (targetCal == 'ical' || (targetCal == 'google' && !/GMT[+|-]\d{1,2}|Etc\/U|Etc\/Zulu|CET|CST6CDT|EET|EST|MET|MST|PST8PDT|WET/i.test(data.timeZone))) {
|
|
3351
3347
|
return {
|
|
3352
3348
|
start: atcb_format_datetime(newStartDate, 'clean', true, true),
|
|
3353
3349
|
end: atcb_format_datetime(newEndDate, 'clean', true, true),
|
|
@@ -3669,7 +3665,7 @@ function atcb_secure_url(url, throwError = true) {
|
|
|
3669
3665
|
}
|
|
3670
3666
|
}
|
|
3671
3667
|
function atcb_validEmail(email) {
|
|
3672
|
-
if (!/^.{0,70}@.{1,30}\.[a-
|
|
3668
|
+
if (!/^.{0,70}@.{1,30}\.[a-z]{2,9}$/i.test(email)) {
|
|
3673
3669
|
return false;
|
|
3674
3670
|
}
|
|
3675
3671
|
return true;
|
|
@@ -3687,9 +3683,9 @@ function atcb_rewrite_html_elements(content, clear = false, iCalBreaks = false)
|
|
|
3687
3683
|
content = content.replace(/\{url\}(.+?)\{\/url\}/gi, (match, p1) => {
|
|
3688
3684
|
return p1.split('|')[0];
|
|
3689
3685
|
});
|
|
3690
|
-
content = content.replace(/\[(
|
|
3691
|
-
content = content.replace(/\{(
|
|
3692
|
-
content = content.replace(/&[#a-
|
|
3686
|
+
content = content.replace(/\[\/?(hr|[pbui]|strong|em|li|ul|ol|h\d)\]/gi, '');
|
|
3687
|
+
content = content.replace(/\{\/?(hr|[pbui]|strong|em|li|ul|ol|h\d)\}/gi, '');
|
|
3688
|
+
content = content.replace(/&[#a-z0-9]{1,9};/gi, '');
|
|
3693
3689
|
} else {
|
|
3694
3690
|
content = content.replace(/\[url\]((?:(?!\[\/url\]).)*)\[\/url\]/gi, function (match, p1) {
|
|
3695
3691
|
return atcb_parse_url_code(p1);
|
|
@@ -3697,8 +3693,8 @@ function atcb_rewrite_html_elements(content, clear = false, iCalBreaks = false)
|
|
|
3697
3693
|
content = content.replace(/\{url\}((?:(?!\[\/url\]).)*)\{\/url\}/gi, function (match, p1) {
|
|
3698
3694
|
return atcb_parse_url_code(p1);
|
|
3699
3695
|
});
|
|
3700
|
-
content = content.replace(/\[(
|
|
3701
|
-
content = content.replace(/\{(
|
|
3696
|
+
content = content.replace(/\[(\/)?(br|hr|[pbui]|strong|em|li|ul|ol|h\d)(\s?\/?)\]/gi, '<$1$2$3>');
|
|
3697
|
+
content = content.replace(/\{(\/)?(br|hr|[pbui]|strong|em|li|ul|ol|h\d)(\s?\/?)\}/gi, '<$1$2$3>');
|
|
3702
3698
|
}
|
|
3703
3699
|
return content;
|
|
3704
3700
|
}
|
|
@@ -4908,7 +4904,7 @@ if (atcbIsBrowser()) {
|
|
|
4908
4904
|
this.data.identifier = this.identifier;
|
|
4909
4905
|
} else {
|
|
4910
4906
|
if (this.data.identifier && this.data.identifier !== '') {
|
|
4911
|
-
if (!/^[\w
|
|
4907
|
+
if (!/^[\w-]+$/.test(this.data.identifier)) {
|
|
4912
4908
|
this.data.identifier = '';
|
|
4913
4909
|
if (this.debug) {
|
|
4914
4910
|
let prefix = 'Add to Calendar Button';
|
|
@@ -5106,7 +5102,7 @@ async function atcb_load_css(host, rootObj = null, data) {
|
|
|
5106
5102
|
const cssGlobalContent = document.createElement('style');
|
|
5107
5103
|
cssGlobalContent.id = 'atcb-global-style';
|
|
5108
5104
|
const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
5109
|
-
cssGlobalContent.innerText = '.atcb-modal-no-scroll{overflow-y:hidden !important;-webkit-overflow-scrolling:touch;} body.atcb-modal-no-scroll{padding-right:' + scrollBarWidth + 'px;}';
|
|
5105
|
+
cssGlobalContent.innerText = '.atcb-modal-no-scroll{overflow-y:hidden !important;-webkit-overflow-scrolling:touch;} body.atcb-modal-no-scroll{padding-right:' + scrollBarWidth + 'px;}.atcb-attribution{display:none;}';
|
|
5110
5106
|
if (nonceVal) {
|
|
5111
5107
|
cssGlobalContent.setAttribute('nonce', nonceVal);
|
|
5112
5108
|
}
|
|
@@ -5255,7 +5251,7 @@ async function atcb_action(inputData, triggerElement, keyboardTrigger = false) {
|
|
|
5255
5251
|
if (triggerElement.id && triggerElement.id !== '') {
|
|
5256
5252
|
data.identifier = triggerElement.id;
|
|
5257
5253
|
} else {
|
|
5258
|
-
if (data.identifier && data.identifier != '' && /^[\w
|
|
5254
|
+
if (data.identifier && data.identifier != '' && /^[\w-]+$/.test(data.identifier)) {
|
|
5259
5255
|
data.identifier = 'atcb-btn-' + data.identifier;
|
|
5260
5256
|
} else {
|
|
5261
5257
|
data.identifier = 'atcb-btn-custom';
|