Skip to content

Commit

Permalink
Version 2.7 (release)
Browse files Browse the repository at this point in the history
  • Loading branch information
foroco committed Apr 27, 2023
1 parent ead674c commit 80d7bae
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this `PHP Browser Detection` project documented in this file.

## [2.7] - 2023-04-27

### Fixed

- Gecko browser engine issue fixed for Gecko versions > 109 for correct Gecko version detection (see issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1806690)

## [2.6] - 2023-03-12

### Added
Expand Down
15 changes: 12 additions & 3 deletions src/BrowserDetection.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @version 2.6
* @last-modified March 12, 2023
* @version 2.7
* @last-modified April 27, 2023
* @link https://github.com/foroco/php-browser-detection
*/

Expand Down Expand Up @@ -938,6 +938,14 @@ private function getResult()
if (!empty($match[1])) $this->result_browser_gecko_version = intval($match[1]);
}
}

// Gecko >= 109 issue

if ($this->result_browser_gecko_version >= 109)
{
$match = $this->match_ua('/\srv:[0-9]+\.[0-9]+\)\sGecko\/[.0-9]+\s.*Firefox\/([0-9]+)\./');
if (!empty($match[1])) $this->result_browser_gecko_version = intval($match[1]);
}
}

// WebKit engine detection
Expand Down Expand Up @@ -1006,7 +1014,7 @@ private function getResult()
$browser_list[] = array('Cyberfox', 'Cyberfox/', '/Cyberfox\/([0-9]+)/', '1', '');
$browser_list[] = array('SeaMonkey', 'SeaMonkey/', '/SeaMonkey\/([0-9]+\.[0-9]+)/', '1', '');
$browser_list[] = array('K-Meleon', 'K-Meleon', '/K\-Meleon\/([0-9]+\.[0-9]+)/', '1', '');
$browser_list[] = array('Iceweasel', '/Ice[wW]easel/', '/Ice[wW]easel(\/|\s)([0-9]+\.[0-9]+)/', '2', '');
$browser_list[] = array('Iceweasel', '/[iI]ce[wW]easel/', '/[iI]ce[wW]easel/', '1', '');
$browser_list[] = array('IceApe', 'Iceape/', '/Iceape\/([0-9]+\.[0-9]+)/', '1', '');
$browser_list[] = array('Comodo Ice Dragon', 'IceDragon/', '/IceDragon\/([0-9]+\.[0-9]+)/', '1', '');
$browser_list[] = array('QtWeb', 'QtWeb Internet Browser/', '/QtWeb\sInternet\sBrowser\/([0-9]+\.[0-9]+)/', '1', '');
Expand Down Expand Up @@ -1381,6 +1389,7 @@ private function getResult()
$browsers_without_versions[] = 'Pinterest App';
$browsers_without_versions[] = 'Ali App';
$browsers_without_versions[] = 'Alipay App';
$browsers_without_versions[] = 'Iceweasel';

if (in_array($this->result_browser_name, $browsers_without_versions) || isset($darwin_app))
{
Expand Down
38 changes: 38 additions & 0 deletions tests/gecko_issue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

require_once('../src/BrowserDetection.php');
$Browser = new foroco\BrowserDetection();

// Testing new Gecko based User-Agent strings

$useragent[] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:108.0) Gecko/20100101 Firefox/108.0';
$useragent[] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:109.0) Gecko/20100101 Firefox/109.0';
$useragent[] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:109.0) Gecko/20100101 Firefox/110.0';

$time_start = microtime(true);

foreach ($useragent as $u)
{
// Detect possible environment data from User-Agents
$result = $Browser->getAll($u);

echo '<div style="font-size:16px; font-weight:bold"><pre>';
echo $u;
echo '</pre></div>';

echo '<div style="font-size:18px; font-weight:bold"><pre>';
print_r($result);
echo '</pre></div>';

echo '<div style="font-size:16px; font-weight:bold"><pre>';
echo '--------------------------------------------------------------------------------';
echo '</pre></div>';

}

$time_end = microtime(true);
$time_result = $time_end - $time_start;

echo '<p style="font-size:21px">Total execution time: '.substr($time_result,0,7).' sec.</p>';

?>

0 comments on commit 80d7bae

Please sign in to comment.