Developer Fixes Silent Regex Bug in Formbricks That Crashed Live Surveys

A contributor discovered a runtime bug in Formbricks, an open-source survey platform with over 12,000 GitHub stars, where invalid regex patterns entered by survey creators were accepted without validation. The flaw existed because the schema only checked that the pattern field was a non-empty string, without verifying it was a legitimate regular expression. This meant a malformed pattern like '[invalid' could be saved to the database and only cause a JavaScript SyntaxError when a real user attempted to submit a response, silently crashing the survey. The fix adds two helper functions that wrap RegExp construction in try/catch blocks, rejecting invalid patterns and flags at the schema level before they reach the database. Placing the validation at the schema layer ensures malformed inputs are blocked even if submitted directly via the API, bypassing any frontend checks.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in