mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-31 20:39:11 -06:00
fix: wrap custom inline scripts in try-catch to prevent ReferenceError crashes
This commit is contained in:
@@ -56,9 +56,16 @@ export const CustomScriptsInjector = ({
|
||||
newScript.setAttribute(attr.name, attr.value);
|
||||
});
|
||||
|
||||
// Copy inline script content
|
||||
// Copy inline script content with error handling
|
||||
if (script.textContent) {
|
||||
newScript.textContent = script.textContent;
|
||||
// Wrap inline scripts in try-catch to prevent user script errors from breaking the survey
|
||||
newScript.textContent = `
|
||||
try {
|
||||
${script.textContent}
|
||||
} catch (error) {
|
||||
console.warn('[Formbricks] Error in custom script:', error);
|
||||
}
|
||||
`.trim();
|
||||
}
|
||||
|
||||
document.head.appendChild(newScript);
|
||||
|
||||
Reference in New Issue
Block a user