From 3395f5603699aa5a76cadbbea64db4ca8c681f4e Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 19 May 2019 08:45:29 -0400 Subject: [PATCH] Add Unicode support to autolink regular expression - Explicitly exclude non-breaking spaces from URLs as \s doesn't include them --- src/Util/Strings.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Util/Strings.php b/src/Util/Strings.php index b2b710d96..3f8990d6c 100644 --- a/src/Util/Strings.php +++ b/src/Util/Strings.php @@ -355,25 +355,25 @@ class Strings */ public static function autoLinkRegEx() { - return '@(?xi) + return '@ (??«»“”‘’.] # Domain can\'t start with a . - [^/\s`!()\[\]{};:\'",<>?«»“”‘’]+ # Domain can\'t end with a . + [^/\s\xA0`!()\[\]{};:\'",<>?«»“”‘’.] # Domain can\'t start with a . + [^/\s\xA0`!()\[\]{};:\'",<>?«»“”‘’]+ # Domain can\'t end with a . \. - [^/\s`!()\[\]{};:\'".,<>?«»“”‘’]+/? # Followed by a slash + [^/\s\xA0`!()\[\]{};:\'".,<>?«»“”‘’]+/? # Followed by a slash ) (?: # One or more: - [^\s()<>]+ # Run of non-space, non-()<> + [^\s\xA0()<>]+ # Run of non-space, non-()<> | # or - \(([^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels + \(([^\s\xA0()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels | # or - [^\s`!()\[\]{};:\'".,<>?«»“”‘’] # not a space or one of these punct chars + [^\s\xA0`!()\[\]{};:\'".,<>?«»“”‘’] # not a space or one of these punct chars )* -)@'; +)@xiu'; } /**