From d2f7f84041f6d37a52c424b1b495d81ed446295f Mon Sep 17 00:00:00 2001 From: ozh Date: Sun, 2 Apr 2017 18:29:31 +0200 Subject: [PATCH] Tune regexp parsing. Fixes #2155 We make a regexp from the charset, and used to specify that `-` was to be escaped but this has been fixed in PHP 5.2 We now escape `@`, which is also used as the regexp delimiter in yourls-loader.php, so now `@` can also be used in short URL charset --- includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/functions.php b/includes/functions.php index e416361..6b91997 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -29,7 +29,7 @@ function yourls_get_shorturl_charset() { * */ function yourls_make_regexp_pattern( $string ) { - $pattern = preg_quote( $string, '-' ); // add - as an escaped characters -- this is fixed in PHP 5.3 + $pattern = preg_quote( $string, '@' ); // add @ as an escaped character because @ is used as the regexp delimiter in yourls-loader.php // Simple benchmarks show that regexp with smarter sequences (0-9, a-z, A-Z...) are not faster or slower than 0123456789 etc... return $pattern; } -- 2.42.0