Skip to content

Commit 0ce7c2a

Browse files
Treat relative ur is as same site in chat responses (#2410)
* Update ChatMessage.js * Add relative URI checker to helperFunctions.js
1 parent d1355fd commit 0ce7c2a

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎lhc_web/design/defaulttheme/widget/react-app/src/components/ChatMessage.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,9 @@ class ChatMessage extends PureComponent {
386386
if (this.props.embedMode && this.props.embedMode == 'widget' && this.props.targetSame && cloneAttr.target && cloneAttr.target == '_blank' && domNode.attribs.href) {
387387
const href = domNode.attribs.href;
388388
const parentHost = window.parent.location.host;
389-
const isSameHost = href.startsWith(`http://${parentHost}`) || href.startsWith(`https://${parentHost}`);
389+
const isSameHost = href.startsWith(`http://${parentHost}`)
390+
|| href.startsWith(`https://${parentHost}`)
391+
|| helperFunctions.isRelativeURI(href);
390392
if (isSameHost) {
391393
if (domNode.attribs.style) {
392394
domNode.attribs.style = this.getStyleObjectFromString(domNode.attribs.style);

‎lhc_web/design/defaulttheme/widget/react-app/src/lib/helperFunctions.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ class _helperFunctions {
179179
}
180180
}
181181

182+
isRelativeURI(uri) {
183+
if (uri.startsWith('//')) return false;
184+
try { new URL(uri); return false; }
185+
catch { return true; }
186+
}
187+
182188
logJSError(params) {
183189
var e;
184190
e = {};
@@ -196,4 +202,4 @@ class _helperFunctions {
196202

197203
const helperFunctions = new _helperFunctions();
198204
window.lhcHelperfunctions = helperFunctions;
199-
export { helperFunctions };
205+
export { helperFunctions };

0 commit comments

Comments
 (0)