Browse Source

Improved parsing of AngularJS URLS.

The AngularJS URLS may contain ; and !, they broke (parsed partially).
Sevvlor 8 years ago
parent
commit
9e8a9c14f0
2 changed files with 9 additions and 1 deletions
  1. 1 1
      src/View/Helper/TextHelper.php
  2. 8 0
      tests/TestCase/View/Helper/TextHelperTest.php

+ 1 - 1
src/View/Helper/TextHelper.php

@@ -123,7 +123,7 @@ class TextHelper extends Helper
                     (?<left>[\[<(]) # left paren,brace
                     (?>
                         # Lax match URL
-                        (?<url>(?:https?|ftp|nntp):\/\/[\p{L}0-9.\-_:]+(?:[\/?][\p{L}0-9.\-_:\/?=&>\[\]()#@\+~%]+)?)
+                        (?<url>(?:https?|ftp|nntp):\/\/[\p{L}0-9.\-_:]+(?:[\/?][\p{L}0-9.\-_:\/?=&>\[\]()#@\+~!;%]+)?)
                         (?<right>[\])>]) # right paren,brace
                     )
                 )

+ 8 - 0
tests/TestCase/View/Helper/TextHelperTest.php

@@ -368,6 +368,14 @@ class TextHelperTest extends TestCase
             [
                 'https://sevvlor.com/page%20not%20found',
                 '<a href="https://sevvlor.com/page%20not%20found">https://sevvlor.com/page%20not%20found</a>'
+            ],
+            [
+                'https://fakedomain.ext/path/#!topic/test',
+                '<a href="https://fakedomain.ext/path/#!topic/test">https://fakedomain.ext/path/#!topic/test</a>'
+            ],
+            [
+                'https://fakedomain.ext/path/#!topic/test;other;tag',
+                '<a href="https://fakedomain.ext/path/#!topic/test;other;tag">https://fakedomain.ext/path/#!topic/test;other;tag</a>'
             ]
         ];
     }