BotFramework-WebChat
BotFramework-WebChat copied to clipboard
webchat.js:2 Uncaught SyntaxError: Invalid regular expression: /\p{P}/: Invalid escape
Is it an issue related to Adaptive Cards?
No
Is this an accessibility issue?
No
What version of Web Chat are you using?
Latest production
Which distribution are you using Web Chat from?
IFRAME
Which hosting environment does this issue primarily affect?
Electron
Which browsers and platforms do the issue happened?
Platform: Windows
Which area does this issue affect?
Development experience
What is the public URL for the website?
https://polarisbot-test.microsoft.com/
Please describe the bug
I am opening the bot using an iframe like this :
<iframe src={this.state.url} style={{ height: "100%", width: "100%", backgroundColor: "black" }}></iframe>
to open the bot in an electron application where the url is https://polarisbot-test.microsoft.com/ I consistently get this error on the console as provided below and then it is followed by this error
?mode=dark&copilot=fcshell:238)
at fire (jquery-3.6.0.js:3500)
at Object.fireWith [as resolveWith] (jquery-3.6.0.js:3630)
at done (jquery-3.6.0.js:9796)
at XMLHttpRequest.<anonymous> (jquery-3.6.0.js:10057)
I load the webChat.js this way in the bot code
<head>
<meta charset="UTF-8" />
<title>Polaris Bot</title>
<script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
</head>
and then I use the window.webchat like this
var directLine = window.WebChat.createDirectLine({
token: data.Token
});
console.log("window.webChat with directLine", directLine);
// render web chat widget that enables chatting with polaris bot
window.WebChat.renderWebChat(
{
directLine: directLine,
userID: activityUserId,
locale: 'en-US',
styleOptions,
overrideLocalizedStrings: {
TEXT_INPUT_PLACEHOLDER: 'Type your message here. Tip: type "help" to get the list of chat commands supported. type "cancel" or "quit" to end an ongoing dialog with me.'
}
},
document.getElementById('webchat')
);
Do you see any errors in console log?
webchat.js:2 Uncaught SyntaxError: Invalid regular expression: /\p{P}/: Invalid escape
at Module.51638 (webchat.js:2)
at r (webchat.js:2)
at Object.9316 (webchat.js:2)
at r (webchat.js:2)
at Object.67090 (webchat.js:2)
at r (webchat.js:2)
at Object.9998 (webchat.js:2)
at r (webchat.js:2)
at Object.34654 (webchat.js:2)
at r (webchat.js:2)
How to reproduce the issue?
I face this issue strictly when I use <script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
in the header
When I change the script to use <script src="https://cdn.botframework.com/botframework-webchat/4.15.9/webchat.js"></script>
it works again
What do you expect?
I need to get rid of this error message It strictly occurs when I use the latest version and not 4.15.9
What actually happened?
When I load my electron application, I have a window on the left side which basically loads the iframe with the bot url . But the bot never loads, instead it throws errors as provided in the description
Do you have any screenshots or recordings to repro the issue?
Adaptive Card JSON
No response
Additional context
No response
@Amey819 what exact electron version are you using?
"electron": "2.0.9", "electron-winstaller": "2.6.0", "electron-config": "0.2.1", "electron-context-menu": "0.8.0", "electron-devtools-installer": "2.2.4", "electron-regedit": "1.0.6", "electron-squirrel-startup": "1.0.0", "electron-mocha": "^8.0.2",
@Amey819 please either use the ES5 build (https://cdn.botframework.com/botframework-webchat/latest/webchat-es5.js), or upgrade the Electron to the latest version (latest: 29.0.1
to the date)
@OEvgeny I see the same error when I use https://cdn.botframework.com/botframework-webchat/latest/webchat-es5.js as well
We cant really go with the 2nd option to update electron as it can cause a lot of backward compatibilty issues for us
This was working seemlesssly till v 4.15.9 but broke recently on the latest
@Amey819 the release date of the version was 2018-09-10. The version is using Chrome 57 along with NodeJS 8.9.3, which both are not supported already and have a lot of publicly discussed security vulnerabilities.
If you really can't, I suggest pinning WebChat to the latest working version for now until you get the chance to update.
The error seems to be specifically happening around parsing a string, Is there a way to debug exactly what is causing that error?
@Amey819 The error is caused by an older Chrome engine not recognizing the regular expression /\p{P}/
due to the lack of support of the \p
escape class: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape
According to MDN the support was introduced in Chrome 64 while Electon v2.0.9 uses Chrome v57.