Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

urls with cyrillic bug #1

Open
thegobot opened this issue Sep 10, 2018 · 0 comments
Open

urls with cyrillic bug #1

thegobot opened this issue Sep 10, 2018 · 0 comments

Comments

@thegobot
Copy link

Example

$linkify = new \Nahid\Linkify\Linkify();
$text = $linkify->process("https://ru.wikipedia.org/wiki/Бультерьер");
var_dump($text);
var_dump(json_encode($text));

string(114) "<a href="https://ru.wikipedia.org/wiki/Бультерье�">https://ru.wikipedia.org/wiki/Бультерье�</a>�"

bool(false)

Add to https://github.com/nahid/linkify/blob/master/src/Nahid/Linkify/Linkify.php#L142
regexp modifier u

        $pattern = '~(?xi)
              (?:
                ((ht|f)tps?://)                    # scheme://
                |                                  #   or
                www\d{0,3}\.                       # "www.", "www1.", "www2." ... "www999."
                |                                  #   or
                www\-                              # "www-"
                |                                  #   or
                [a-z0-9.\-]+\.[a-z]{2,4}(?=/)      # looks like domain name followed by a slash
              )
              (?:                                  # Zero or more:
                [^\s()<>]+                         # Run of non-space, non-()<>
                |                                  #   or
                \(([^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels
              )*
              (?:                                  # End with:
                \(([^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels
                |                                  #   or
                [^\s`!\-()\[\]{};:\'".,<>?«»“”‘’]  # not a space or one of these punct chars
              )
        ~u';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant