From fbf449c85ca09718d6e02aff7375c41eea26c2aa Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 17 Dec 2019 11:24:52 +0100 Subject: [PATCH 1/4] Fix compatibility to php 7.4 --- Urlizer.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Urlizer.php b/Urlizer.php index af7bf67..af5e0cb 100644 --- a/Urlizer.php +++ b/Urlizer.php @@ -221,13 +221,13 @@ public static function utf8ToAscii($str, $unknown = '?') foreach ($chars as $i => $c) { $ud = 0; - if (ord($c{0})>=0 && ord($c{0})<=127) { continue; } // ASCII - next please - if (ord($c{0})>=192 && ord($c{0})<=223) { $ord = (ord($c{0})-192)*64 + (ord($c{1})-128); } - if (ord($c{0})>=224 && ord($c{0})<=239) { $ord = (ord($c{0})-224)*4096 + (ord($c{1})-128)*64 + (ord($c{2})-128); } - if (ord($c{0})>=240 && ord($c{0})<=247) { $ord = (ord($c{0})-240)*262144 + (ord($c{1})-128)*4096 + (ord($c{2})-128)*64 + (ord($c{3})-128); } - if (ord($c{0})>=248 && ord($c{0})<=251) { $ord = (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128); } - if (ord($c{0})>=252 && ord($c{0})<=253) { $ord = (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128); } - if (ord($c{0})>=254 && ord($c{0})<=255) { $chars{$i} = $unknown; continue; } //error + if (ord($c[0])>=0 && ord($c[0])<=127) { continue; } // ASCII - next please + if (ord($c[0])>=192 && ord($c[0])<=223) { $ord = (ord($c[0])-192)*64 + (ord($c[1])-128); } + if (ord($c[0])>=224 && ord($c[0])<=239) { $ord = (ord($c[0])-224)*4096 + (ord($c[1])-128)*64 + (ord($c[2])-128); } + if (ord($c[0])>=240 && ord($c[0])<=247) { $ord = (ord($c[0])-240)*262144 + (ord($c[1])-128)*4096 + (ord($c[2])-128)*64 + (ord($c[3])-128); } + if (ord($c[0])>=248 && ord($c[0])<=251) { $ord = (ord($c[0])-248)*16777216 + (ord($c[1])-128)*262144 + (ord($c[2])-128)*4096 + (ord($c[3])-128)*64 + (ord($c[4])-128); } + if (ord($c[0])>=252 && ord($c[0])<=253) { $ord = (ord($c[0])-252)*1073741824 + (ord($c[1])-128)*16777216 + (ord($c[2])-128)*262144 + (ord($c[3])-128)*4096 + (ord($c[4])-128)*64 + (ord($c[5])-128); } + if (ord($c[0])>=254 && ord($c[0])<=255) { $chars[$i] = $unknown; continue; } //error $bank = $ord >> 8; @@ -242,9 +242,9 @@ public static function utf8ToAscii($str, $unknown = '?') $newchar = $ord & 255; if (array_key_exists($newchar, $UTF8_TO_ASCII[$bank])) { - $chars{$i} = $UTF8_TO_ASCII[$bank][$newchar]; + $chars[$i] = $UTF8_TO_ASCII[$bank][$newchar]; } else { - $chars{$i} = $unknown; + $chars[$i] = $unknown; } } @@ -297,7 +297,7 @@ public static function validUtf8($str) $len = strlen($str); for ($i = 0; $i < $len; $i++) { - $in = ord($str{$i}); + $in = ord($str[$i]); if ($mState == 0) { // When mState is zero we expect either a US-ASCII character or a // multi-octet sequence. From 395e64cb6fe48c93d9258e49951669fd7374145d Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 17 Dec 2019 11:33:36 +0100 Subject: [PATCH 2/4] Fix travis ci and add more php versions --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4dadc94..e98a0dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,12 @@ language: php +dist: trusty + php: - 5.3 - 5.4 - + - 7.0 + - 7.4 notifications: email: From 7d6f6ff28f84fd82adb0b9b9854f6094abe95d1e Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 17 Dec 2019 11:47:35 +0100 Subject: [PATCH 3/4] Fix testing matrix --- .travis.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index e98a0dc..5c7322a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,19 @@ language: php -dist: trusty - -php: - - 5.3 - - 5.4 - - 7.0 - - 7.4 +matrix: + include: + - + dist: precise + php: 5.3 + - + dist: precise + php: 5.4 + - + dist: trusty + php: 7.0 + - + dist: trusty + php: 7.4 notifications: email: From 70e65c7d792a6bbc1f9034042f613091687c74ea Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 17 Dec 2019 12:49:34 +0100 Subject: [PATCH 4/4] Delete unused travis file --- .travis.yml | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5c7322a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: php - -matrix: - include: - - - dist: precise - php: 5.3 - - - dist: precise - php: 5.4 - - - dist: trusty - php: 7.0 - - - dist: trusty - php: 7.4 - -notifications: - email: - - arielferrandini@gmail.com