Unexpected behavior with "[" in the search functionality

Issue Summary

There’s a bit of unexpected behavior with the search functionality if you type “[” (left bracket) into the search functionality, and then any other letter or number. Once you type “[” and then any letter or number, it locks you out of the search function until you reload the page or visit a different page.

Steps to Reproduce

  1. Head over to my site at nathanbrown.ghost.io. I use Google Chrome – Version 111.0.5563.64 (Official Build) (arm64) – which appears to be the latest version. I also use a Macbook Air with an M1 chip. My site is hosted with Ghost (Pro) on version 5.38.0.

  2. Press the search button (top right, next to the ‘Sign In’ button).

  3. Type [ and then any number or letter (eg. a, e, 1, 5).

  4. Here’s what happens to me: it kicks me out from the search functionality. If I try to click on the search button again, nothing happens. If I reload the page, the search button begins to work again. (Also, if I type a[ or 1[, once I type the left bracket, it kicks me out from the search functionality and the same things happen.)

Other Information

How did I discover this issue? nathanbrown.ghost.io is my personal blog, and I use the format ‘[#X]’ to number my articles – that’s why I first typed [ into the search functionality.

Interestingly, the right bracket (if you type ] instead of [) doesn’t seem to cause any problems. Also interestingly, I can type other characters (that aren’t letters or numbers, like /, :, ", ',) into the search functionality after I type the left bracket, and it doesn’t crash the search functionality.

So yeah

I would appreciate if you could test out this issue on your own computer – it only takes like 10 seconds. Let me know if there’s any other information that y’all need.

1 Like

That’s a bug! The console error is: SyntaxError: Invalid regular expression: /^[a|\s[a/: Unterminated character class (at PopupModal.js:260:24)
at new RegExp ()
at oe (PopupModal.js:260:24)
at ue (PopupModal.js:273:30)
at ie (PopupModal.js:311:37)
at ai (react-dom.production.min.js:157:137)
at Qa (react-dom.production.min.js:267:460)
at jl (react-dom.production.min.js:250:347)
at Sl (react-dom.production.min.js:250:278)
at kl (react-dom.production.min.js:250:138)
at bl (react-dom.production.min.js:243:163)

– looks like some escaping of [ is missing. That’s the built in search, right? Might be good to open a bug report on it over on Github.


Thanks for this report! We’re tracking this bug already and plan on releasing a fix soon.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.