From 5b45ad986dafe3c9723d8c2c3e56b1f312022420 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Mon, 27 Apr 2020 21:16:10 -0400 Subject: [PATCH] chat: strictly match URLs in outgoing strings Our regex processes true, and sends a message as a URL, if any part of the string is a URL starting with a URI schema. We pass this function strings cut up by spaces. If a link was enclosed in quotes, or in brackets, this would still process as true. This adds ^ to the regex to only process strings that START with a schema. --- pkg/interface/chat/src/js/components/lib/chat-input.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/interface/chat/src/js/components/lib/chat-input.js b/pkg/interface/chat/src/js/components/lib/chat-input.js index 6a61b57f1..3d1f1ba5f 100644 --- a/pkg/interface/chat/src/js/components/lib/chat-input.js +++ b/pkg/interface/chat/src/js/components/lib/chat-input.js @@ -173,7 +173,7 @@ export class ChatInput extends Component { isUrl(string) { try { - const websiteTest = new RegExp(String(/((\w+:\/\/)[-a-zA-Z0-9:@;?&=\/%\+\.\*!'\(\),\$_\{\}\^~\[\]`#|]+)/.source) + const websiteTest = new RegExp(String(/^((\w+:\/\/)[-a-zA-Z0-9:@;?&=\/%\+\.\*!'\(\),\$_\{\}\^~\[\]`#|]+)/.source) ); return websiteTest.test(string); } catch (e) {