From 26b5d8a14f0ede1d6519e2fb5c3b2e4afdde2d23 Mon Sep 17 00:00:00 2001 From: Kane Cohen Date: Thu, 17 Aug 2017 01:31:59 -0700 Subject: [PATCH] Add unicode support. (#23) * Add unicode support. * Add visible unicode tests --- src/Misd/Linkify/Linkify.php | 4 ++-- tests/data/email.json | 8 ++++++++ tests/data/url.json | 8 ++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Misd/Linkify/Linkify.php b/src/Misd/Linkify/Linkify.php index 870bd38..af7bd55 100644 --- a/src/Misd/Linkify/Linkify.php +++ b/src/Misd/Linkify/Linkify.php @@ -160,7 +160,7 @@ protected function linkifyUrls($text, $options = array('attr' => '')) | # or [^\s`!\-()\[\]{};:\'".,<>?«»“”‘’] # not a space or one of these punct chars ) - ~'; + ~u'; $callback = function ($match) use ($options) { $caption = $match[0]; @@ -201,7 +201,7 @@ protected function linkifyEmails($text, $options = array('attr' => '')) [A-Z0-9.-]+ # Domain \. # Dot [A-Z]{2,4} # Something - ~'; + ~u'; $callback = function ($match) use ($options) { if (isset($options['callback'])) { diff --git a/tests/data/email.json b/tests/data/email.json index 5edc6d2..6562f22 100644 --- a/tests/data/email.json +++ b/tests/data/email.json @@ -46,6 +46,14 @@ "test": "example@example.example.com.", "expected": "example@example.example.com." }, + { + "test": "example@example.example.com ", + "expected": "example@example.example.com " + }, + { + "test": "Привет example@example.com!", + "expected": "Привет example@example.com!" + }, { "test": "(example@example.com)", "expected": "(example@example.com)" diff --git a/tests/data/url.json b/tests/data/url.json index 50b3421..2dcfc71 100644 --- a/tests/data/url.json +++ b/tests/data/url.json @@ -38,6 +38,14 @@ "test": "http://www.example.com/example/", "expected": "http://www.example.com/example/" }, + { + "test": "www.example.com ", + "expected": "www.example.com " + }, + { + "test": "Линк: https://ru.wikipedia.org/wiki/Футбол", + "expected": "Линк: https://ru.wikipedia.org/wiki/Футбол" + }, { "test": "(http://www.example.com/)", "expected": "(http://www.example.com/)"