HCAWN / gcal-multical-event-merge

Browser extension that visually merges the same event on multiple Google Calendars into one event.
GNU General Public License v3.0
26 stars 5 forks source link

[BUG] Event titles with unmatched ')' cause regex syntax error -> No merged formatting applied #28

Closed teleksterling closed 3 weeks ago

teleksterling commented 5 months ago

Describe the bug Event titles aren't (properly) escaped, which leads to failures during regex event matching.

This error appears in the log upon page load/refresh 20-30 times within a couple seconds (perhaps once per visible event?)

events.user.js:220 
Uncaught (in promise) SyntaxError: Invalid regular expression: /15_Test ), 8:30am18px/: Unmatched ')' 
    at events.user.js:220:15
    at String.match (<anonymous>)
    at findMatchingString (events.user.js:220:15)
    at events.user.js:242:57
    at Array.forEach (<anonymous>)
    at events.user.js:235:12
    at NodeList.forEach (<anonymous>)
    at merge (events.user.js:233:8)

To Reproduce

  1. Create an event with a title containing a ')', without preceding '(', e.g. "Test me)".
  2. Reload page. All events that should be merged, aren't.
  3. Toggling off the calendar containing the offending event will restore correct formatting for remaining visible calendar items.
  4. Screenshots of how it looks with extension enabled, enabled with triggering event title and disabled with triggering event title

Chrome extension bug report

Expected behaviour

  1. Code should be modified to prevent event text being interpreted as regex syntax.
  2. Visible result should be that screenshot # 2 has merged formatting applied like # 1.

Device

Additional context None. Thanks for forking and improving the extension!

teleksterling commented 5 months ago

This looks useful - but I don't really know javascript:

function escapeRegExp(string) {
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
}

From: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping

HCAWN commented 2 months ago

@teleksterling https://github.com/HCAWN/gcal-multical-event-merge/pull/29/commits/b1a58c5f62f32f78c31b90c439defe9914a616ff Should be fixed in extension version 2.3.7, let me know once the update propigates to your browser through Chome

H

HCAWN commented 3 weeks ago

Closing as I beleive this has been resoled and no update from original poster.