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.
@@ -6,14 +6,14 @@ import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'tim
6
6
  * Add to Calendar Button
7
7
  * ++++++++++++++++++++++
8
8
  *
9
- * Version: 2.6.20
9
+ * Version: 2.6.21
10
10
  * Creator: Jens Kuerschner (https://jekuer.com)
11
11
  * Project: https://github.com/add2cal/add-to-calendar-button
12
12
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
13
13
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
14
14
  *
15
15
  */
16
- const atcbVersion = '2.6.20';
16
+ const atcbVersion = '2.6.21';
17
17
  const atcbCssTemplate = {};
18
18
  const atcbIsBrowser = () => {
19
19
  if (typeof window === 'undefined') {
@@ -57,7 +57,7 @@ const atcbIsAndroid = atcbIsBrowser()
57
57
  };*/
58
58
  const atcbIsSafari = atcbIsBrowser()
59
59
  ? () => {
60
- if (/^((?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent)) {
60
+ if (/^(?:(?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent)) {
61
61
  return true;
62
62
  } else {
63
63
  return false;
@@ -75,7 +75,7 @@ const atcbIsMobile = () => {
75
75
  };
76
76
  const atcbIsWebView = atcbIsBrowser()
77
77
  ? () => {
78
- if (/(; ?wv|(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari))/i.test(navigator.userAgent)) {
78
+ if (/; ?wv|(?:iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent)) {
79
79
  return true;
80
80
  } else {
81
81
  return false;
@@ -86,7 +86,7 @@ const atcbIsWebView = atcbIsBrowser()
86
86
  };
87
87
  const atcbIsProblematicWebView = atcbIsBrowser()
88
88
  ? () => {
89
- if (/(Instagram)/i.test(navigator.userAgent)) {
89
+ if (/Instagram/i.test(navigator.userAgent)) {
90
90
  return true;
91
91
  } else {
92
92
  return false;
@@ -305,7 +305,7 @@ function atcb_decorate_data_timezone(tz = null) {
305
305
  function atcb_decorate_data_rrule(data) {
306
306
  if (data.recurrence && data.recurrence !== '') {
307
307
  data.recurrence = data.recurrence.replace(/\s+/g, '').toUpperCase();
308
- if (!/^(RRULE:[\w=;,:+-/\\]+|daily|weekly|monthly|yearly)$/im.test(data.recurrence)) {
308
+ if (!/^(?:RRULE:[\w=;,:+\-/\\]+|daily|weekly|monthly|yearly)$/im.test(data.recurrence)) {
309
309
  data.recurrence = '!wrong rrule format!';
310
310
  } else {
311
311
  if (/^RRULE:/i.test(data.recurrence)) {
@@ -548,8 +548,7 @@ function atcb_decorate_data_description(data, i) {
548
548
  description = cleanDescription(description);
549
549
  if (data.customVar) {
550
550
  for (const key in data.customVar) {
551
- const sanitizedKey = key.replace(/[^a-zA-Z0-9\-_.]/g, '');
552
- // eslint-disable-next-line security/detect-non-literal-regexp
551
+ const sanitizedKey = key.replace(/[^\w\-.]/g, '');
553
552
  description = description.replace(new RegExp(`%%${sanitizedKey}%%`, 'g'), data.customVar[`${key}`]);
554
553
  }
555
554
  }
@@ -608,10 +607,8 @@ function atcb_decorate_data_extend(data) {
608
607
  }
609
608
  if (data.customVar) {
610
609
  for (const key in data.customVar) {
611
- const sanitizedKey = key.replace(/[^a-zA-Z0-9\-_.]/g, '');
612
- // eslint-disable-next-line security/detect-non-literal-regexp
610
+ const sanitizedKey = key.replace(/[^\w\-.]/g, '');
613
611
  data.dates[`${i}`].name = data.dates[`${i}`].name.replace(new RegExp(`%%${sanitizedKey}%%`, 'g'), data.customVar[`${key}`]);
614
- // eslint-disable-next-line security/detect-non-literal-regexp
615
612
  data.dates[`${i}`].location = data.dates[`${i}`].location.replace(new RegExp(`%%${sanitizedKey}%%`, 'g'), data.customVar[`${key}`]);
616
613
  }
617
614
  }
@@ -630,7 +627,7 @@ function atcb_date_cleanup(dateTimeData) {
630
627
  }
631
628
  const endpoints = ['start', 'end'];
632
629
  endpoints.forEach(function (point) {
633
- if (!/^(\d{4}-\d{2}-\d{2}T?(?:\d{2}:\d{2}|)Z?|today(?:\+\d{1,4}|))$/i.test(dateTimeData[point + 'Date'])) {
630
+ if (!/^(?:\d{4}-\d{2}-\d{2}T?(?:\d{2}:\d{2})?Z?|today(?:\+\d{1,4})?)$/i.test(dateTimeData[point + 'Date'])) {
634
631
  dateTimeData[point + 'Date'] = 'badly-formed';
635
632
  } else {
636
633
  dateTimeData[point + 'Date'] = atcb_date_calculation(dateTimeData[point + 'Date']);
@@ -835,7 +832,7 @@ async function atcb_validate_buttonStyle(data, msgPrefix) {
835
832
  if (!availableStyles.includes(data.buttonStyle)) {
836
833
  throw new Error(msgPrefix + ' failed: provided buttonStyle invalid');
837
834
  }
838
- if (data.customCss && data.customCss !== '' && (!atcb_secure_url(data.customCss, false) || !/\.css($|\?)/.test(data.customCss))) {
835
+ if (data.customCss && data.customCss !== '' && (!atcb_secure_url(data.customCss, false) || !/\.css(?:$|\?)/.test(data.customCss))) {
839
836
  throw new Error(msgPrefix + ' failed: customCss provided, but no valid url');
840
837
  }
841
838
  if ((!data.customCss || data.customCss === '') && data.buttonStyle === 'custom') {
@@ -936,7 +933,7 @@ async function atcb_validate_attendee(data, msgPrefix, i, msgSuffix) {
936
933
  return true;
937
934
  }
938
935
  async function atcb_validate_uid(data, msgPrefix, i, msgSuffix) {
939
- if (!/^(\w|-){1,254}$/.test(data.dates[`${i}`].uid)) {
936
+ if (!/^(?:\w|-){1,254}$/.test(data.dates[`${i}`].uid)) {
940
937
  if (data.debug) {
941
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);
942
939
  }
@@ -1005,7 +1002,7 @@ async function atcb_validate_rrule(data, msgPrefix) {
1005
1002
  if (data.recurrence && data.recurrence !== '' && data.dates.length > 1) {
1006
1003
  throw new Error(msgPrefix + ' failed: RRULE and multi-date set at the same time');
1007
1004
  }
1008
- if (data.recurrence && data.recurrence !== '' && !/^RRULE:[\w=;,:+-/\\]+$/i.test(data.recurrence)) {
1005
+ if (data.recurrence && data.recurrence !== '' && !/^RRULE:[\w=;,:+\-/\\]+$/i.test(data.recurrence)) {
1009
1006
  throw new Error(msgPrefix + ' failed: RRULE data misspelled');
1010
1007
  }
1011
1008
  return true;
@@ -1014,22 +1011,22 @@ async function atcb_validate_rrule_simplyfied(data, msgPrefix) {
1014
1011
  if (data.recurrence_interval && (data.recurrence_interval < 1 || data.recurrence_interval % 1 !== 0)) {
1015
1012
  throw new Error(msgPrefix + ' failed: recurrence data (interval) misspelled');
1016
1013
  }
1017
- if (data.recurrence_until && data.recurrence_until !== '' && !/^(\d|-|:)+$/i.test(data.recurrence_until)) {
1014
+ if (data.recurrence_until && data.recurrence_until !== '' && !/^[\d\-:]+$/.test(data.recurrence_until)) {
1018
1015
  throw new Error(msgPrefix + ' failed: recurrence data (until) misspelled');
1019
1016
  }
1020
1017
  if (data.recurrence_count && (data.recurrence_count < 1 || data.recurrence_count % 1 !== 0)) {
1021
1018
  throw new Error(msgPrefix + ' failed: recurrence data (interval) misspelled');
1022
1019
  }
1023
- if (data.recurrence_byMonth && data.recurrence_byMonth !== '' && !/^(\d|,)+$/.test(data.recurrence_byMonth)) {
1020
+ if (data.recurrence_byMonth && data.recurrence_byMonth !== '' && !/^[\d,]+$/.test(data.recurrence_byMonth)) {
1024
1021
  throw new Error(msgPrefix + ' failed: recurrence data (byMonth) misspelled');
1025
1022
  }
1026
- if (data.recurrence_byMonthDay && data.recurrence_byMonthDay !== '' && !/^(\d|,)+$/.test(data.recurrence_byMonthDay)) {
1023
+ if (data.recurrence_byMonthDay && data.recurrence_byMonthDay !== '' && !/^[\d,]+$/.test(data.recurrence_byMonthDay)) {
1027
1024
  throw new Error(msgPrefix + ' failed: recurrence data (byMonthDay) misspelled');
1028
1025
  }
1029
- if (data.recurrence_byDay && data.recurrence_byDay !== '' && !/^(\d|-|MO|TU|WE|TH|FR|SA|SU|,)+$/im.test(data.recurrence_byDay)) {
1026
+ if (data.recurrence_byDay && data.recurrence_byDay !== '' && !/^(?:[\d,-]|MO|TU|WE|TH|FR|SA|SU)+$/im.test(data.recurrence_byDay)) {
1030
1027
  throw new Error(msgPrefix + ' failed: recurrence data (byDay) misspelled');
1031
1028
  }
1032
- 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)) {
1033
1030
  throw new Error(msgPrefix + ' failed: recurrence data (weekstart) misspelled');
1034
1031
  }
1035
1032
  return true;
@@ -1540,7 +1537,8 @@ function atcb_create_atcbl(host, atList = true, returnEl = false, licenseNoteOnl
1540
1537
  }
1541
1538
  } else {
1542
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).';
1543
- atcbL.setAttribute('style', 'none !important');
1540
+ atcbL.setAttribute('style', 'display:none !important');
1541
+ atcbL.classList.add('atcb-attribution');
1544
1542
  host.append(atcbL);
1545
1543
  }
1546
1544
  if (returnEl) return null;
@@ -2217,7 +2215,7 @@ function atcb_subscribe_ical(data, fileUrl) {
2217
2215
  function atcb_subscribe_google(data, fileUrl) {
2218
2216
  const baseUrl = 'https://calendar.google.com/calendar/r?cid=';
2219
2217
  const baseUrlApp = 'calendar.google.com/calendar?cid=';
2220
- const fileUrlRegex = /^(https?:\/\/|webcal:\/\/|\/\/)calendar\.google\.com\//;
2218
+ const fileUrlRegex = /^(?:https?:\/\/|webcal:\/\/|\/\/)calendar\.google\.com\//;
2221
2219
  const newFileUrl = (function () {
2222
2220
  if (fileUrlRegex.test(fileUrl)) {
2223
2221
  return fileUrl.replace(/^(.)*\?cid=/, '');
@@ -2252,7 +2250,7 @@ function atcb_generate_google(data, date, subEvent = 'all') {
2252
2250
  urlParts.push('https://calendar.google.com/calendar/render?action=TEMPLATE');
2253
2251
  const formattedDate = atcb_generate_time(date, 'clean', 'google');
2254
2252
  urlParts.push('dates=' + encodeURIComponent(formattedDate.start) + '%2F' + encodeURIComponent(formattedDate.end));
2255
- if (date.timeZone && date.timeZone !== '' && !/(GMT[+|-]\d{1,2}|Etc\/U|Etc\/Zulu|CET|CST6CDT|EET|EST|EST5EDT|MET|MST|MST7MDT|PST8PDT|WET)/i.test(date.timeZone) && !formattedDate.allday) {
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) {
2256
2254
  urlParts.push('ctz=' + date.timeZone);
2257
2255
  }
2258
2256
  if (date.name && date.name !== '') {
@@ -2403,7 +2401,6 @@ function atcb_open_cal_url(data, type, url, subscribe = false, subEvent = null,
2403
2401
  return;
2404
2402
  }
2405
2403
  }
2406
- // eslint-disable-next-line security/detect-non-literal-fs-filename
2407
2404
  const newTab = window.open(url, target);
2408
2405
  if (newTab) {
2409
2406
  newTab.focus();
@@ -2625,7 +2622,7 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', a
2625
2622
  }
2626
2623
  return durationHours + ':' + ('0' + durationMinutes).slice(-2);
2627
2624
  })();
2628
- if (targetCal == 'ical' || (targetCal == 'google' && !/(GMT[+|-]\d{1,2}|Etc\/U|Etc\/Zulu|CET|CST6CDT|EET|EST|EST5EDT|MET|MST|MST7MDT|PST8PDT|WET)/i.test(data.timeZone))) {
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))) {
2629
2626
  return {
2630
2627
  start: atcb_format_datetime(newStartDate, 'clean', true, true),
2631
2628
  end: atcb_format_datetime(newEndDate, 'clean', true, true),
@@ -2947,7 +2944,7 @@ function atcb_secure_url(url, throwError = true) {
2947
2944
  }
2948
2945
  }
2949
2946
  function atcb_validEmail(email) {
2950
- if (!/^.{0,70}@.{1,30}\.[a-zA-Z]{2,9}$/.test(email)) {
2947
+ if (!/^.{0,70}@.{1,30}\.[a-z]{2,9}$/i.test(email)) {
2951
2948
  return false;
2952
2949
  }
2953
2950
  return true;
@@ -2965,9 +2962,9 @@ function atcb_rewrite_html_elements(content, clear = false, iCalBreaks = false)
2965
2962
  content = content.replace(/\{url\}(.+?)\{\/url\}/gi, (match, p1) => {
2966
2963
  return p1.split('|')[0];
2967
2964
  });
2968
- content = content.replace(/\[(|\/)(hr|p|b|strong|u|i|em|li|ul|ol|h\d)\]/gi, '');
2969
- content = content.replace(/\{(|\/)(hr|p|b|strong|u|i|em|li|ul|ol|h\d)\}/gi, '');
2970
- content = content.replace(/&[#a-zA-Z0-9]{1,9};/gi, '');
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, '');
2971
2968
  } else {
2972
2969
  content = content.replace(/\[url\]((?:(?!\[\/url\]).)*)\[\/url\]/gi, function (match, p1) {
2973
2970
  return atcb_parse_url_code(p1);
@@ -2975,8 +2972,8 @@ function atcb_rewrite_html_elements(content, clear = false, iCalBreaks = false)
2975
2972
  content = content.replace(/\{url\}((?:(?!\[\/url\]).)*)\{\/url\}/gi, function (match, p1) {
2976
2973
  return atcb_parse_url_code(p1);
2977
2974
  });
2978
- content = content.replace(/\[(\/|)(br|hr|p|b|strong|u|i|em|li|ul|ol|h\d)(\s?\/?)\]/gi, '<$1$2$3>');
2979
- content = content.replace(/\{(\/|)(br|hr|p|b|strong|u|i|em|li|ul|ol|h\d)(\s?\/?)\}/gi, '<$1$2$3>');
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>');
2980
2977
  }
2981
2978
  return content;
2982
2979
  }
@@ -4186,7 +4183,7 @@ if (atcbIsBrowser()) {
4186
4183
  this.data.identifier = this.identifier;
4187
4184
  } else {
4188
4185
  if (this.data.identifier && this.data.identifier !== '') {
4189
- if (!/^[\w\-_]+$/.test(this.data.identifier)) {
4186
+ if (!/^[\w-]+$/.test(this.data.identifier)) {
4190
4187
  this.data.identifier = '';
4191
4188
  if (this.debug) {
4192
4189
  let prefix = 'Add to Calendar Button';
@@ -4384,7 +4381,7 @@ async function atcb_load_css(host, rootObj = null, data) {
4384
4381
  const cssGlobalContent = document.createElement('style');
4385
4382
  cssGlobalContent.id = 'atcb-global-style';
4386
4383
  const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;
4387
- 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;}';
4388
4385
  if (nonceVal) {
4389
4386
  cssGlobalContent.setAttribute('nonce', nonceVal);
4390
4387
  }
@@ -4533,7 +4530,7 @@ async function atcb_action(inputData, triggerElement, keyboardTrigger = false) {
4533
4530
  if (triggerElement.id && triggerElement.id !== '') {
4534
4531
  data.identifier = triggerElement.id;
4535
4532
  } else {
4536
- if (data.identifier && data.identifier != '' && /^[\w\-_]+$/.test(data.identifier)) {
4533
+ if (data.identifier && data.identifier != '' && /^[\w-]+$/.test(data.identifier)) {
4537
4534
  data.identifier = 'atcb-btn-' + data.identifier;
4538
4535
  } else {
4539
4536
  data.identifier = 'atcb-btn-custom';
@@ -6,14 +6,14 @@ import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'tim
6
6
  * Add to Calendar Button
7
7
  * ++++++++++++++++++++++
8
8
  *
9
- * Version: 2.6.20
9
+ * Version: 2.6.21
10
10
  * Creator: Jens Kuerschner (https://jekuer.com)
11
11
  * Project: https://github.com/add2cal/add-to-calendar-button
12
12
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
13
13
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
14
14
  *
15
15
  */
16
- const atcbVersion = '2.6.20';
16
+ const atcbVersion = '2.6.21';
17
17
  const atcbCssTemplate = {};
18
18
  const atcbIsBrowser = () => {
19
19
  if (typeof window === 'undefined') {
@@ -57,7 +57,7 @@ const atcbIsAndroid = atcbIsBrowser()
57
57
  };*/
58
58
  const atcbIsSafari = atcbIsBrowser()
59
59
  ? () => {
60
- if (/^((?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent)) {
60
+ if (/^(?:(?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent)) {
61
61
  return true;
62
62
  } else {
63
63
  return false;
@@ -75,7 +75,7 @@ const atcbIsMobile = () => {
75
75
  };
76
76
  const atcbIsWebView = atcbIsBrowser()
77
77
  ? () => {
78
- if (/(; ?wv|(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari))/i.test(navigator.userAgent)) {
78
+ if (/; ?wv|(?:iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent)) {
79
79
  return true;
80
80
  } else {
81
81
  return false;
@@ -86,7 +86,7 @@ const atcbIsWebView = atcbIsBrowser()
86
86
  };
87
87
  const atcbIsProblematicWebView = atcbIsBrowser()
88
88
  ? () => {
89
- if (/(Instagram)/i.test(navigator.userAgent)) {
89
+ if (/Instagram/i.test(navigator.userAgent)) {
90
90
  return true;
91
91
  } else {
92
92
  return false;
@@ -305,7 +305,7 @@ function atcb_decorate_data_timezone(tz = null) {
305
305
  function atcb_decorate_data_rrule(data) {
306
306
  if (data.recurrence && data.recurrence !== '') {
307
307
  data.recurrence = data.recurrence.replace(/\s+/g, '').toUpperCase();
308
- if (!/^(RRULE:[\w=;,:+-/\\]+|daily|weekly|monthly|yearly)$/im.test(data.recurrence)) {
308
+ if (!/^(?:RRULE:[\w=;,:+\-/\\]+|daily|weekly|monthly|yearly)$/im.test(data.recurrence)) {
309
309
  data.recurrence = '!wrong rrule format!';
310
310
  } else {
311
311
  if (/^RRULE:/i.test(data.recurrence)) {
@@ -548,8 +548,7 @@ function atcb_decorate_data_description(data, i) {
548
548
  description = cleanDescription(description);
549
549
  if (data.customVar) {
550
550
  for (const key in data.customVar) {
551
- const sanitizedKey = key.replace(/[^a-zA-Z0-9\-_.]/g, '');
552
- // eslint-disable-next-line security/detect-non-literal-regexp
551
+ const sanitizedKey = key.replace(/[^\w\-.]/g, '');
553
552
  description = description.replace(new RegExp(`%%${sanitizedKey}%%`, 'g'), data.customVar[`${key}`]);
554
553
  }
555
554
  }
@@ -608,10 +607,8 @@ function atcb_decorate_data_extend(data) {
608
607
  }
609
608
  if (data.customVar) {
610
609
  for (const key in data.customVar) {
611
- const sanitizedKey = key.replace(/[^a-zA-Z0-9\-_.]/g, '');
612
- // eslint-disable-next-line security/detect-non-literal-regexp
610
+ const sanitizedKey = key.replace(/[^\w\-.]/g, '');
613
611
  data.dates[`${i}`].name = data.dates[`${i}`].name.replace(new RegExp(`%%${sanitizedKey}%%`, 'g'), data.customVar[`${key}`]);
614
- // eslint-disable-next-line security/detect-non-literal-regexp
615
612
  data.dates[`${i}`].location = data.dates[`${i}`].location.replace(new RegExp(`%%${sanitizedKey}%%`, 'g'), data.customVar[`${key}`]);
616
613
  }
617
614
  }
@@ -630,7 +627,7 @@ function atcb_date_cleanup(dateTimeData) {
630
627
  }
631
628
  const endpoints = ['start', 'end'];
632
629
  endpoints.forEach(function (point) {
633
- if (!/^(\d{4}-\d{2}-\d{2}T?(?:\d{2}:\d{2}|)Z?|today(?:\+\d{1,4}|))$/i.test(dateTimeData[point + 'Date'])) {
630
+ if (!/^(?:\d{4}-\d{2}-\d{2}T?(?:\d{2}:\d{2})?Z?|today(?:\+\d{1,4})?)$/i.test(dateTimeData[point + 'Date'])) {
634
631
  dateTimeData[point + 'Date'] = 'badly-formed';
635
632
  } else {
636
633
  dateTimeData[point + 'Date'] = atcb_date_calculation(dateTimeData[point + 'Date']);
@@ -835,7 +832,7 @@ async function atcb_validate_buttonStyle(data, msgPrefix) {
835
832
  if (!availableStyles.includes(data.buttonStyle)) {
836
833
  throw new Error(msgPrefix + ' failed: provided buttonStyle invalid');
837
834
  }
838
- if (data.customCss && data.customCss !== '' && (!atcb_secure_url(data.customCss, false) || !/\.css($|\?)/.test(data.customCss))) {
835
+ if (data.customCss && data.customCss !== '' && (!atcb_secure_url(data.customCss, false) || !/\.css(?:$|\?)/.test(data.customCss))) {
839
836
  throw new Error(msgPrefix + ' failed: customCss provided, but no valid url');
840
837
  }
841
838
  if ((!data.customCss || data.customCss === '') && data.buttonStyle === 'custom') {
@@ -936,7 +933,7 @@ async function atcb_validate_attendee(data, msgPrefix, i, msgSuffix) {
936
933
  return true;
937
934
  }
938
935
  async function atcb_validate_uid(data, msgPrefix, i, msgSuffix) {
939
- if (!/^(\w|-){1,254}$/.test(data.dates[`${i}`].uid)) {
936
+ if (!/^(?:\w|-){1,254}$/.test(data.dates[`${i}`].uid)) {
940
937
  if (data.debug) {
941
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);
942
939
  }
@@ -1005,7 +1002,7 @@ async function atcb_validate_rrule(data, msgPrefix) {
1005
1002
  if (data.recurrence && data.recurrence !== '' && data.dates.length > 1) {
1006
1003
  throw new Error(msgPrefix + ' failed: RRULE and multi-date set at the same time');
1007
1004
  }
1008
- if (data.recurrence && data.recurrence !== '' && !/^RRULE:[\w=;,:+-/\\]+$/i.test(data.recurrence)) {
1005
+ if (data.recurrence && data.recurrence !== '' && !/^RRULE:[\w=;,:+\-/\\]+$/i.test(data.recurrence)) {
1009
1006
  throw new Error(msgPrefix + ' failed: RRULE data misspelled');
1010
1007
  }
1011
1008
  return true;
@@ -1014,22 +1011,22 @@ async function atcb_validate_rrule_simplyfied(data, msgPrefix) {
1014
1011
  if (data.recurrence_interval && (data.recurrence_interval < 1 || data.recurrence_interval % 1 !== 0)) {
1015
1012
  throw new Error(msgPrefix + ' failed: recurrence data (interval) misspelled');
1016
1013
  }
1017
- if (data.recurrence_until && data.recurrence_until !== '' && !/^(\d|-|:)+$/i.test(data.recurrence_until)) {
1014
+ if (data.recurrence_until && data.recurrence_until !== '' && !/^[\d\-:]+$/.test(data.recurrence_until)) {
1018
1015
  throw new Error(msgPrefix + ' failed: recurrence data (until) misspelled');
1019
1016
  }
1020
1017
  if (data.recurrence_count && (data.recurrence_count < 1 || data.recurrence_count % 1 !== 0)) {
1021
1018
  throw new Error(msgPrefix + ' failed: recurrence data (interval) misspelled');
1022
1019
  }
1023
- if (data.recurrence_byMonth && data.recurrence_byMonth !== '' && !/^(\d|,)+$/.test(data.recurrence_byMonth)) {
1020
+ if (data.recurrence_byMonth && data.recurrence_byMonth !== '' && !/^[\d,]+$/.test(data.recurrence_byMonth)) {
1024
1021
  throw new Error(msgPrefix + ' failed: recurrence data (byMonth) misspelled');
1025
1022
  }
1026
- if (data.recurrence_byMonthDay && data.recurrence_byMonthDay !== '' && !/^(\d|,)+$/.test(data.recurrence_byMonthDay)) {
1023
+ if (data.recurrence_byMonthDay && data.recurrence_byMonthDay !== '' && !/^[\d,]+$/.test(data.recurrence_byMonthDay)) {
1027
1024
  throw new Error(msgPrefix + ' failed: recurrence data (byMonthDay) misspelled');
1028
1025
  }
1029
- if (data.recurrence_byDay && data.recurrence_byDay !== '' && !/^(\d|-|MO|TU|WE|TH|FR|SA|SU|,)+$/im.test(data.recurrence_byDay)) {
1026
+ if (data.recurrence_byDay && data.recurrence_byDay !== '' && !/^(?:[\d,-]|MO|TU|WE|TH|FR|SA|SU)+$/im.test(data.recurrence_byDay)) {
1030
1027
  throw new Error(msgPrefix + ' failed: recurrence data (byDay) misspelled');
1031
1028
  }
1032
- 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)) {
1033
1030
  throw new Error(msgPrefix + ' failed: recurrence data (weekstart) misspelled');
1034
1031
  }
1035
1032
  return true;
@@ -2261,7 +2258,8 @@ function atcb_create_atcbl(host, atList = true, returnEl = false, licenseNoteOnl
2261
2258
  }
2262
2259
  } else {
2263
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).';
2264
- atcbL.setAttribute('style', 'none !important');
2261
+ atcbL.setAttribute('style', 'display:none !important');
2262
+ atcbL.classList.add('atcb-attribution');
2265
2263
  host.append(atcbL);
2266
2264
  }
2267
2265
  if (returnEl) return null;
@@ -2938,7 +2936,7 @@ function atcb_subscribe_ical(data, fileUrl) {
2938
2936
  function atcb_subscribe_google(data, fileUrl) {
2939
2937
  const baseUrl = 'https://calendar.google.com/calendar/r?cid=';
2940
2938
  const baseUrlApp = 'calendar.google.com/calendar?cid=';
2941
- const fileUrlRegex = /^(https?:\/\/|webcal:\/\/|\/\/)calendar\.google\.com\//;
2939
+ const fileUrlRegex = /^(?:https?:\/\/|webcal:\/\/|\/\/)calendar\.google\.com\//;
2942
2940
  const newFileUrl = (function () {
2943
2941
  if (fileUrlRegex.test(fileUrl)) {
2944
2942
  return fileUrl.replace(/^(.)*\?cid=/, '');
@@ -2973,7 +2971,7 @@ function atcb_generate_google(data, date, subEvent = 'all') {
2973
2971
  urlParts.push('https://calendar.google.com/calendar/render?action=TEMPLATE');
2974
2972
  const formattedDate = atcb_generate_time(date, 'clean', 'google');
2975
2973
  urlParts.push('dates=' + encodeURIComponent(formattedDate.start) + '%2F' + encodeURIComponent(formattedDate.end));
2976
- if (date.timeZone && date.timeZone !== '' && !/(GMT[+|-]\d{1,2}|Etc\/U|Etc\/Zulu|CET|CST6CDT|EET|EST|EST5EDT|MET|MST|MST7MDT|PST8PDT|WET)/i.test(date.timeZone) && !formattedDate.allday) {
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) {
2977
2975
  urlParts.push('ctz=' + date.timeZone);
2978
2976
  }
2979
2977
  if (date.name && date.name !== '') {
@@ -3124,7 +3122,6 @@ function atcb_open_cal_url(data, type, url, subscribe = false, subEvent = null,
3124
3122
  return;
3125
3123
  }
3126
3124
  }
3127
- // eslint-disable-next-line security/detect-non-literal-fs-filename
3128
3125
  const newTab = window.open(url, target);
3129
3126
  if (newTab) {
3130
3127
  newTab.focus();
@@ -3346,7 +3343,7 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', a
3346
3343
  }
3347
3344
  return durationHours + ':' + ('0' + durationMinutes).slice(-2);
3348
3345
  })();
3349
- if (targetCal == 'ical' || (targetCal == 'google' && !/(GMT[+|-]\d{1,2}|Etc\/U|Etc\/Zulu|CET|CST6CDT|EET|EST|EST5EDT|MET|MST|MST7MDT|PST8PDT|WET)/i.test(data.timeZone))) {
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))) {
3350
3347
  return {
3351
3348
  start: atcb_format_datetime(newStartDate, 'clean', true, true),
3352
3349
  end: atcb_format_datetime(newEndDate, 'clean', true, true),
@@ -3668,7 +3665,7 @@ function atcb_secure_url(url, throwError = true) {
3668
3665
  }
3669
3666
  }
3670
3667
  function atcb_validEmail(email) {
3671
- if (!/^.{0,70}@.{1,30}\.[a-zA-Z]{2,9}$/.test(email)) {
3668
+ if (!/^.{0,70}@.{1,30}\.[a-z]{2,9}$/i.test(email)) {
3672
3669
  return false;
3673
3670
  }
3674
3671
  return true;
@@ -3686,9 +3683,9 @@ function atcb_rewrite_html_elements(content, clear = false, iCalBreaks = false)
3686
3683
  content = content.replace(/\{url\}(.+?)\{\/url\}/gi, (match, p1) => {
3687
3684
  return p1.split('|')[0];
3688
3685
  });
3689
- content = content.replace(/\[(|\/)(hr|p|b|strong|u|i|em|li|ul|ol|h\d)\]/gi, '');
3690
- content = content.replace(/\{(|\/)(hr|p|b|strong|u|i|em|li|ul|ol|h\d)\}/gi, '');
3691
- content = content.replace(/&[#a-zA-Z0-9]{1,9};/gi, '');
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, '');
3692
3689
  } else {
3693
3690
  content = content.replace(/\[url\]((?:(?!\[\/url\]).)*)\[\/url\]/gi, function (match, p1) {
3694
3691
  return atcb_parse_url_code(p1);
@@ -3696,8 +3693,8 @@ function atcb_rewrite_html_elements(content, clear = false, iCalBreaks = false)
3696
3693
  content = content.replace(/\{url\}((?:(?!\[\/url\]).)*)\{\/url\}/gi, function (match, p1) {
3697
3694
  return atcb_parse_url_code(p1);
3698
3695
  });
3699
- content = content.replace(/\[(\/|)(br|hr|p|b|strong|u|i|em|li|ul|ol|h\d)(\s?\/?)\]/gi, '<$1$2$3>');
3700
- content = content.replace(/\{(\/|)(br|hr|p|b|strong|u|i|em|li|ul|ol|h\d)(\s?\/?)\}/gi, '<$1$2$3>');
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>');
3701
3698
  }
3702
3699
  return content;
3703
3700
  }
@@ -4907,7 +4904,7 @@ if (atcbIsBrowser()) {
4907
4904
  this.data.identifier = this.identifier;
4908
4905
  } else {
4909
4906
  if (this.data.identifier && this.data.identifier !== '') {
4910
- if (!/^[\w\-_]+$/.test(this.data.identifier)) {
4907
+ if (!/^[\w-]+$/.test(this.data.identifier)) {
4911
4908
  this.data.identifier = '';
4912
4909
  if (this.debug) {
4913
4910
  let prefix = 'Add to Calendar Button';
@@ -5105,7 +5102,7 @@ async function atcb_load_css(host, rootObj = null, data) {
5105
5102
  const cssGlobalContent = document.createElement('style');
5106
5103
  cssGlobalContent.id = 'atcb-global-style';
5107
5104
  const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;
5108
- 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;}';
5109
5106
  if (nonceVal) {
5110
5107
  cssGlobalContent.setAttribute('nonce', nonceVal);
5111
5108
  }
@@ -5254,7 +5251,7 @@ async function atcb_action(inputData, triggerElement, keyboardTrigger = false) {
5254
5251
  if (triggerElement.id && triggerElement.id !== '') {
5255
5252
  data.identifier = triggerElement.id;
5256
5253
  } else {
5257
- if (data.identifier && data.identifier != '' && /^[\w\-_]+$/.test(data.identifier)) {
5254
+ if (data.identifier && data.identifier != '' && /^[\w-]+$/.test(data.identifier)) {
5258
5255
  data.identifier = 'atcb-btn-' + data.identifier;
5259
5256
  } else {
5260
5257
  data.identifier = 'atcb-btn-custom';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "add-to-calendar-button",
3
- "version": "2.6.20",
3
+ "version": "2.6.21",
4
4
  "engines": {
5
5
  "node": ">=18.17.0",
6
6
  "npm": ">=9.6.7"
@@ -83,8 +83,8 @@
83
83
  "release": "node set-release.js",
84
84
  "stylelint": "npx stylelint assets/css/*.css",
85
85
  "stylelint:fix": "npm run stylelint -- --fix",
86
- "eslint": "npx eslint --ext \".ts,.js\" .",
87
- "eslint:fix": "npm run eslint -- --fix",
86
+ "eslint": "eslint .",
87
+ "eslint:fix": "eslint --fix .",
88
88
  "prettier": "npx prettier . --check",
89
89
  "prettier:fix": "npm run prettier -- --write",
90
90
  "format": "npm run eslint:fix && npm run prettier:fix && npm run stylelint:fix && cd demo && npm run lint:fix && npm run prettier:fix",
@@ -99,14 +99,13 @@
99
99
  "timezones-ical-library": "^1.8.3"
100
100
  },
101
101
  "devDependencies": {
102
+ "@eslint/js": "^9.11.1",
102
103
  "@open-wc/testing": "^4.0.0",
103
- "@typescript-eslint/eslint-plugin": "^8.6.0",
104
- "@typescript-eslint/parser": "^8.6.0",
105
104
  "@web/test-runner": "^0.19.0",
106
- "eslint": "^8.57.0",
105
+ "eslint": "^9.11.1",
107
106
  "eslint-config-prettier": "^9.1.0",
108
- "eslint-plugin-commonjs": "^1.0.2",
109
107
  "eslint-plugin-prettier": "^5.2.1",
108
+ "eslint-plugin-regexp": "^2.6.0",
110
109
  "eslint-plugin-security": "^3.0.1",
111
110
  "eslint-plugin-wc": "^2.1.1",
112
111
  "grunt": ">=1.6.1",
@@ -117,7 +116,7 @@
117
116
  "grunt-file-creator": "^0.1.3",
118
117
  "grunt-version": "^3.0.1",
119
118
  "prettier": "3.3.3",
120
- "prettier-plugin-tailwindcss": "^0.6.6",
119
+ "prettier-plugin-tailwindcss": "^0.6.8",
121
120
  "stylelint": "^16.9.0",
122
121
  "stylelint-config-standard": "^36.0.1"
123
122
  }
@@ -1,6 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-require-imports */
2
- /* eslint-disable no-undef */
3
-
4
1
  // simple import of the atcb JS, to ensure it can load in Node
5
2
  // it shall not run on the server, but also should not block it!
6
3
  require('../dist/commonjs/index.js');
package/test/test-prep.js CHANGED
@@ -1,7 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-require-imports */
2
- /* eslint-disable no-undef */
3
- /* eslint-disable @typescript-eslint/no-var-requires */
4
- // eslint-disable-next-line security/detect-child-process
5
1
  const execSync = require('child_process').execSync;
6
2
 
7
3
  // preparing the files
@@ -1,6 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- /* eslint-disable no-undef */
3
-
4
1
  import { fixture, html, expect } from '@open-wc/testing';
5
2
  import '../../dist/module/index.js';
6
3
 
package/.eslintrc.json DELETED
@@ -1,36 +0,0 @@
1
- {
2
- "root": true,
3
-
4
- "env": {
5
- "browser": true,
6
- "node": true,
7
- "es6": true
8
- },
9
-
10
- "parserOptions": {
11
- "sourceType": "module",
12
- "parser": "@typescript-eslint/parser",
13
- "xss/no-mixed-html": [
14
- 2,
15
- {
16
- "functions": {
17
- ".encodeURIComponent": {
18
- "passthrough": { "obj": true, "args": true }
19
- }
20
- }
21
- }
22
- ]
23
- },
24
-
25
- "extends": ["plugin:@typescript-eslint/recommended", "eslint:recommended", "plugin:security/recommended-legacy", "plugin:prettier/recommended", "plugin:wc/recommended"],
26
-
27
- "plugins": ["@typescript-eslint", "prettier"],
28
-
29
- "ignorePatterns": ["*.min.*", "dist/*", "demo/*", "Gruntfile.js", "set-release.js"],
30
-
31
- "rules": {
32
- // TO-DO: Enable rules to find and optimize code style
33
- "eqeqeq": 0,
34
- "curly": 0
35
- }
36
- }
@@ -1 +0,0 @@
1
- { "extends": "../../.eslintrc.json", "env": { "node": true }, "plugins": ["commonjs"] }