diff --git a/app/Util/Lexer/Regex.php b/app/Util/Lexer/Regex.php index ecc468d05..f8d77c95f 100755 --- a/app/Util/Lexer/Regex.php +++ b/app/Util/Lexer/Regex.php @@ -162,7 +162,7 @@ abstract class Regex // look-ahead capture here and don't append $after when we return. $tmp['valid_mention_preceding_chars'] = '([^a-zA-Z0-9_!#\$%&*@@\/]|^|(?:^|[^a-z0-9_+~.-])RT:?)'; - $re['valid_mentions_or_lists'] = '/'.$tmp['valid_mention_preceding_chars'].'(['.$tmp['at_signs'].'])([a-z0-9_\-.]{1,20})((\/[a-z][a-z0-9_\-]{0,24})?(?=(.*|$))(?:@[a-z0-9\.\-]+[a-z0-9]+)?)/i'; + $re['valid_mentions_or_lists'] = '/'.$tmp['valid_mention_preceding_chars'].'(['.$tmp['at_signs'].'])([\p{L}0-9_\-.]{1,20})((\/[a-z][a-z0-9_\-]{0,24})?(?=(.*|$))(?:@[a-z0-9\.\-]+[a-z0-9]+)?)/iu'; $re['valid_reply'] = '/^(?:['.$tmp['spaces'].'])*['.$tmp['at_signs'].']([a-z0-9_\-.]{1,20})(?=(.*|$))/iu'; $re['end_mention_match'] = '/\A(?:['.$tmp['at_signs'].']|['.$tmp['latin_accents'].']|:\/\/)/iu'; diff --git a/tests/Unit/Lexer/UsernameTest.php b/tests/Unit/Lexer/UsernameTest.php index 0d21b6e00..64875df7e 100644 --- a/tests/Unit/Lexer/UsernameTest.php +++ b/tests/Unit/Lexer/UsernameTest.php @@ -175,4 +175,67 @@ class UsernameTest extends TestCase $this->assertEquals($expectedEntity, $entities); } + /** @test * */ + public function germanUmlatsAutolink() + { + $mentions = "@März and @königin and @Glück"; + $autolink = Autolink::create()->autolink($mentions); + + $expectedAutolink = '@März and @königin and @Glück'; + $this->assertEquals($expectedAutolink, $autolink); + } + + /** @test * */ + public function germanUmlatsExtractor() + { + $mentions = "@März and @königin and @Glück"; + $entities = Extractor::create()->extract($mentions); + + $expectedEntity = [ + "hashtags" => [], + "urls" => [], + "mentions" => [ + "märz", + "königin", + "glück", + ], + "replyto" => null, + "hashtags_with_indices" => [], + "urls_with_indices" => [], + "mentions_with_indices" => [ + [ + "screen_name" => "März", + "indices" => [ + 0, + 5, + ], + ], + [ + "screen_name" => "königin", + "indices" => [ + 10, + 18, + ], + ], + [ + "screen_name" => "Glück", + "indices" => [ + 23, + 29, + ], + ], + ], + ]; + $this->assertEquals($expectedEntity, $entities); + } + + /** @test * */ + public function germanUmlatsWebfingerAutolink() + { + $mentions = "hello @märz@example.org!"; + $autolink = Autolink::create()->autolink($mentions); + + $expectedAutolink = 'hello @märz@example.org!'; + $this->assertEquals($expectedAutolink, $autolink); + } }