Code Monkey home page Code Monkey logo

browscap's Introduction

Browser Capabilities Project

Continuous Integration codecov

This tool is used to build and maintain browscap files.

Installation

$ git clone git://github.com/browscap/browscap.git
$ cd browscap
$ curl -s https://getcomposer.org/installer | php
$ php composer.phar install

What's changed in version 6048

  • #2535 Added recent new Apple platforms (Mac OS, iOS and iPadOS)

What's changed in version 6028

BC breaks listed

  • Interface changed for class \Browscap\Data\Factory\UserAgentFactory

What's changed in version 6027

BC breaks listed

  • Strict type hints have been added throughout. This may break some type assumptions made in earlier versions.
  • In many classes Setters and Getters have been removed, the parameters have been moved to the class constructor
  • Some classes are now final - use composition instead of inheritance

What's changed in version 6025

BC breaks listed

  • The grep command and the diff command were removed

Changes

  • The tests for integration testing the source files are split from the other tests
  • Tests on travis use the build pipeline now

Directory Structure

  • bin - Contains executable files
  • build - Contains various builds
  • resources - Files needed to build the various files, also used to validate the capabilities
  • src - The code of this project lives here
  • tests - The testing code of this project lives here

the CLI commands

There is actually only one cli command available.

build

This command is used to build a set of defined browscap files.

bin/browscap build [version]

options

  • version (required) the name of the version that should be built
  • output (optional) the directory where the files should be created
  • resources (optional) the directory where the sources for the build are located
  • coverage (optional) if this option is set, during the build information is added which can be used to generate a coverage report
  • no-zip (optional) if this option is set, no zip file is generated during the build

For further documentation on the build command, see here.

CLI Examples

You can export a new set of browscap files:

$ bin/browscap build 5020-test
Resource folder: <your source dir>
Build folder: <your target dir>
Generating full_asp_browscap.ini [ASP/FULL]
Generating full_php_browscap.ini [PHP/FULL]
Generating browscap.ini [ASP]
Generating php_browscap.ini [PHP]
...
All done.
$

Now you if you look at browscap/browscap.ini you will see a new INI file has been generated.

Usage Examples

How to build a standard set of browscap files

This example assumes that you want to build all *php_browscap.ini files.

$logger = new \Monolog\Logger('browscap'); // or maybe any other PSR-3 compatible Logger

$format = \Browscap\Formatter\FormatterInterface::TYPE_PHP; // you may choose the output format you want, the format must be already supported

$resourceFolder = 'resources/'; // please point to the resources directory inside the project
$buildFolder = ''; // choose the directory where the generated file should be written to

// If you are using one of the predefined WriterFactories, you may not choose the file names
$writerCollection = (new \Browscap\Writer\Factory\PhpWriterFactory())->createCollection($logger, $buildFolder);

$dataCollectionFactory = new \Browscap\Data\Factory\DataCollectionFactory($logger);

$buildGenerator = new BuildGenerator(
    $resourceFolder,
    $buildFolder,
    $logger,
    $writerCollection,
    $dataCollectionFactory
);

$version       = '';    // what you want to be written into the generated file
$createZipFile = false; // It is not possible yet to create a zipped version of a custom named browscap file

$buildGenerator->run($version, $createZipFile);

How to build a custom set of browscap files

If you want to build a custom set of browscap files, you may not use the predefined WriterFactories.

$logger = new \Monolog\Logger('browscap'); // or maybe any other PSR-3 compatible Logger

$format = \Browscap\Formatter\FormatterInterface::TYPE_PHP; // you may choose the output format you want, the format must be already supported

$resourceFolder = 'resources/'; // please point to the resources directory inside the project
$buildFolder = ''; // choose the directory where the generated file should be written to

$propertyHolder = new \Browscap\Data\PropertyHolder();

// build a standard version browscap.json file
$jsonFormatter = new \Browscap\Formatter\JsonFormatter($propertyHolder);
$jsonFilter    = new \Browscap\Filter\StandardFilter($propertyHolder);

$jsonWriter = new \Browscap\Writer\JsonWriter('relative path or name of the target file', $logger);
$jsonWriter->setFormatter($jsonFormatter);
$jsonWriter->setFilter($jsonFilter);

// build a lite version browscap.xml file
$xmlFormatter = new \Browscap\Formatter\XmlFormatter($propertyHolder);
$xmlFilter    = new \Browscap\Filter\LiteFilter($propertyHolder);

$xmlWriter = new \Browscap\Writer\XmlWriter('relative path or name of the target file', $logger);
$xmlWriter->setFormatter($xmlFormatter);
$xmlWriter->setFilter($xmlFilter);

$writerCollection = new \Browscap\Writer\WriterCollection();
$writerCollection->addWriter($jsonWriter);
$writerCollection->addWriter($xmlWriter);

$dataCollectionFactory = new \Browscap\Data\Factory\DataCollectionFactory($logger);

$buildGenerator = new BuildGenerator(
    $resourceFolder,
    $buildFolder,
    $logger,
    $writerCollection,
    $dataCollectionFactory
);

$version       = '';    // what you want to be written into the generated file
$createZipFile = false; // It is not possible yet to create a zipped version of a custom named browscap file

$buildGenerator->run($version, $createZipFile);

How to build a custom browscap.ini

If you want to build a custom browscap file you may choose the file name and the fields which are included.

Note: It is not possible to build a custom browscap.ini file with the CLI command.

$logger = new \Monolog\Logger('browscap'); // or maybe any other PSR-3 compatible Logger
// If using Monolog, you need specify a log handler, e.g. for STDOUT: $logger->pushHandler(new \Monolog\Handler\ErrorLogHandler());

$format = \Browscap\Formatter\FormatterInterface::TYPE_PHP; // you may choose the output format you want, the format must be already supported
$file   = null; // you may set a custom file name here
$fields = []; // choose the fields you want inside of your browscap file

$resourceFolder = 'resources/'; // please point to the resources directory inside the project
$buildFolder = ''; // choose the directory where the generated file should be written to

$writerCollection = (new \Browscap\Writer\Factory\CustomWriterFactory())->createCollection($logger, $buildFolder, $file, $fields, $format);

$dataCollectionFactory = new \Browscap\Data\Factory\DataCollectionFactory($logger);

$buildGenerator = new BuildGenerator(
    $resourceFolder,
    $buildFolder,
    $logger,
    $writerCollection,
    $dataCollectionFactory
);

$version       = ''; // version you want to be written into the generated file
$dateTime      = new \DateTimeImmutable(); // date you want to be written into the generated file
$createZipFile = false; // It is not possible yet to create a zipped version of a custom named browscap file

$buildGenerator->run($version, $dateTime, $createZipFile);

Issues and feature requests

Please report your issues and ask for new features on the GitHub Issue Tracker at https://github.com/browscap/browscap/issues

Contributing

For instructions on how to contribute see the CONTRIBUTE.md file.

License

See the LICENSE file.

browscap's People

Contributors

abuchmann-ga avatar allie avatar asgrim avatar aumel avatar chappy84 avatar dependabot-preview[bot] avatar dependabot[bot] avatar jasonf20 avatar jaydiablo avatar jmalloc avatar joshuaestes avatar koenr-bc avatar laziel avatar mikhainin avatar mimmi20 avatar mmorel-35 avatar ocluf avatar parisholley avatar paulrutter avatar prox2k avatar radmoose avatar scrutinizer-auto-fixer avatar skoshelev avatar wggdeveloper avatar willyaranda avatar xathz avatar zefling avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

browscap's Issues

Firefox 23

From: https://groups.google.com/forum/#!topic/browscap/AXH0V7wnPrQ

Hi,
Just noticed on my Galaxy Note 8.0 that Firefox 23 is not recognized as a mobile device.
I am using the latest version of browscap.ini (5020)

var_dump(getBrowser('Mozilla/5.0 (Android; Tablet; rv:23.0) Gecko/23.0 Firefox/23.0');

object(stdClass)[343]
public 'browser_name' => string 'Mozilla/5.0 (Android; Tablet; rv:23.0) Gecko/23.0 Firefox/23.0' (length=62)
public 'browser_name_regex' => string '^mozilla/5.0 (._android.tablet.)._gecko/.firefox/(\d)(\d)..$' (length=68)
public 'browser_name_pattern' => string 'Mozilla/5.0 (Android_Tablet)_Gecko/Firefox/23.' (length=50)
public 'Parent' => string 'Firefox 23.0' (length=12)
public 'Platform' => string 'Android' (length=7)
public 'Device_Name' => string 'Android' (length=7)
public 'Device_Maker' => string 'Google' (length=6)
public 'Comment' => string 'Firefox 23.0' (length=12)
public 'Browser' => string 'Firefox' (length=7)
public 'Version' => string '23.0' (length=4)
public 'MajorVer' => string '23' (length=2)
public 'MinorVer' => string '0' (length=1)
public 'Beta' => boolean true
public 'Win32' => boolean true
public 'Frames' => boolean true
public 'IFrames' => boolean true
public 'Tables' => boolean true
public 'Cookies' => boolean true
public 'JavaScript' => boolean true
public 'JavaApplets' => boolean true
public 'CssVersion' => string '3' (length=1)
public 'RenderingEngine_Name' => string 'Gecko' (length=5)
public 'RenderingEngine_Version' => string '22.0' (length=4)
public 'Platform_Version' => string 'unknown' (length=7)
public 'Platform_Description' => string 'unknown' (length=7)
public 'Alpha' => boolean false
public 'Win16' => boolean false
public 'Win64' => boolean false
public 'BackgroundSounds' => boolean false
public 'VBScript' => boolean false
public 'ActiveXControls' => boolean false
public 'isMobileDevice' => boolean false
public 'isSyndicationReader' => boolean false
public 'Crawler' => boolean false
public 'AolVersion' => string '0' (length=1)

"Safari Generic" for Linux is shown instead of Chrome for Android.

Please see this issue
GaretJax/phpbrowscap#27

Browscap does not identify a whole family of Chrome Mobile for Android browsers and since the user agents also have "Linux" and "Safari" in the string they match the "Safari Generic" entry.

For example Mozilla/5.0 (Linux; Android 4.2.2; Nexus 4 Build/JDQ39E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.90 Mobile Safari/537.36 is supposed to be Chrome Mobile 27.0 on Android 4.2 but get_browser() detects it as Safari on Linux

Midori Browser

The Midori Browser is not recognized (comes as default with Fedora 20)
http://www.midori-browser.org/

Mozilla/5.0 (X11; Linux) AppleWebKit/537.32 (KHTML, like Gecko) Chrome/18.0.1025.133 Safari/537.32 Midori/0.5

returns a Unknown on version 5021-rc1

IE11 on Windows8 has several UAs (?)

Using cloned repo and building 5021-b7

My httpd (apache 2.2.x, PHP 5.3.25 on FreeBSD 9) sees my windows8-pro IE11 test (installed in a virtual machine) with the following UA:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident/7.0; Touch; .NET4.0E; .NET4.0C; Tablet PC 2.0)
Which results in "Default Browser" and empty attributes.

But, visiting http://browscap.org/ua-lookup with the same navigator shows:
Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; Touch; rv:11.0) like Gecko

Could you please add this UA to IE11 ?

Thank you

Waterfox Browser

Waterfox is a 64bits version of firefox for windows and is not recognized
www.waterfoxproject.org/‎

Mozilla/5.0 (Windows NT; Win64; x64; rv:26.0) Gecko/20100101 Firefox/26.0 Waterfox/26.0

returns a Unknown on version 5021-rc1

Duplicated properties in ini file

Duplicated rows in full_php_browscap.ini (downloaded from site)

[Mozilla/5.0 (*Linux i686*) AppleWebKit/* (KHTML, like Gecko)*Chromium/22.*Chrome/*Safari/*]
Parent=Chromium 22.0
Platform="Linux"
Win32=false
Platform="Linux"
Win32=false

Safari 7.0.1 on OS X Mavericks 10.9.x

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/7.0.1 Safari/537.73.11

Returns platform_version = unknown

Browser Type cahcing issue

I installed this module on my project and it works just fine to detect the current browser using browscap_get_browser() which I am using to apply browser specific stylesheets. However, once that information is retrieved, it is saved in drupal cache and then if I visit the website in some other browser, it still has the stylsheets from the other broswer and I need to clear off drupal cache to get the correct stylesheets for current browser. Is there a way to handle this situation. Any help in this matter will be helpful.

Thanks,
Sumit

Detection of "Firefox OS"

INSERT INTO browscap (useragent, data) VALUES
('Mozilla/5.0 (Mobile; rv:18.0) Gecko/18.0 Firefox/18.0', 0x613a32383a7b733a373a22636f6d6d656e74223b733a31353a2244656661756c742042726f77736572223b733a373a2262726f77736572223b733a31353a2244656661756c742042726f77736572223b733a373a2276657273696f6e223b733a333a22302e30223b733a383a226d616a6f72766572223b733a313a2230223b733a383a226d696e6f72766572223b733a313a2230223b733a383a22706c6174666f726d223b733a373a22756e6b6e6f776e223b733a31363a22706c6174666f726d5f76657273696f6e223b733a373a22756e6b6e6f776e223b733a353a22616c706861223b733a353a2266616c7365223b733a343a2262657461223b733a353a2266616c7365223b733a353a2277696e3136223b733a353a2266616c7365223b733a353a2277696e3332223b733a353a2266616c7365223b733a353a2277696e3634223b733a353a2266616c7365223b733a363a226672616d6573223b733a353a2266616c7365223b733a373a22696672616d6573223b733a353a2266616c7365223b733a363a227461626c6573223b733a353a2266616c7365223b733a373a22636f6f6b696573223b733a353a2266616c7365223b733a31363a226261636b67726f756e64736f756e6473223b733a353a2266616c7365223b733a31303a226a617661736372697074223b733a353a2266616c7365223b733a383a227662736372697074223b733a353a2266616c7365223b733a31313a226a6176616170706c657473223b733a353a2266616c7365223b733a31353a2261637469766578636f6e74726f6c73223b733a353a2266616c7365223b733a31343a2269736d6f62696c65646576696365223b733a343a2274727565223b733a31393a22697373796e6469636174696f6e726561646572223b733a353a2266616c7365223b733a373a22637261776c6572223b733a353a2266616c7365223b733a31303a2263737376657273696f6e223b733a313a2230223b733a31303a22616f6c76657273696f6e223b733a313a2230223b733a393a22757365726167656e74223b733a35333a224d6f7a696c6c612f352e3020284d6f62696c653b2072763a31382e3029204765636b6f2f31382e302046697265666f782f31382e30223b733a32303a2262726f777365725f6e616d655f7061747465726e223b733a313a222a223b7d0a);

Lite version is missing from generation

In issue #9, we discussed dropping the "lite" version of the files. At the moment, the "full" version (with all properties) and the "standard" version are generated, but we currently do not have a flag that determines if a UA should be included in the "lite" version of the file.

Detect Internet Explorer 11

Now this detects as

["browser_name_regex"]=> "?^.*$?"
["browser_name_pattern"]=> "*"
["comment"]=> "Default Browser"
["browser"]=> "Default Browser"

UserAgent: "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; MASMJS; rv:11.0) like Gecko"

Firefox 24.0 appears twice in full_php_browscap.ini

Firefox 24.0 appears two times in full_php_browscap.ini. Also the definitions are in a weird order, other browser definitions are in the middle of Firefox versions.

Originally reported from #47
Using version 5021-rc1

Missing UA - Safari 4 Mobile (Android 4.2)

Mozilla/5.0 (Linux; U; Android 4.2.2; ru-ru; HTC_One_X Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

This is incorrectly identified as Safari 4 on Linux. Should be Safari 4 Mobile on Android (Android 4.2.2 HTC One X default browser).

Reported by @Shamilik

Feature: Identification test script

As mentioned in #22 (and thus, #22 is a dependency of this task), I'd like to run an "integration test", whereby we have a list of UAs, and what browser/version they should identify as (just basic properties to test, not EVERYTHING).

This should be run as part of the build/release process to ensure "common" browsers are identified in the generated INI files. We could even make it part of the build process in the future.

For example, the test data might be something like (may not be valid code):

<?php
return array(
  ['UA' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36', 'Platform' => 'Linux', 'Browser' => 'Chrome', 'Version' => '30.0'],
  ['UA' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:25.0) Gecko/20100101 Firefox/24.0', 'Platform' => 'MacOSX', 'Browser' => 'Firefox', 'Version' => '24.0'],
);

The test would carry out the following steps:

  • Generate a set of INI files in sys_get_temp_dir() (requires #22)
  • Use phpbrowscap\Browscap to load the php_browscap.ini
  • Loop through the list above and run the UA value through the getBrowser(..) method. The rest of the test array properties should be checked against the returned properties.
    • If any properties are not found/not matched, the UA should be marked as failure
    • If the properties are all in order, the UA should be marked as success
  • If any UAs have been marked as a failure, return a non-zero value so that the build (e.g. on Travis-CI) will be marked as a failure (check that this is the correct method!)

Android 4.3

UA:

Mozilla/5.0 (Linux; Android 4.3; Nexus 4 Build/JWR66Y) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.82 Mobile Safari/537.36

After I added the following rule to the file, it now works for me:

[Mozilla/5.0 (Linux*Android 4.3*)*AppleWebKit/*(*KHTML, like Gecko*)*Chrome/30.*Safari/*]
Parent=Chrome 30.0
Platform="Android"
Platform_Version=4.3
Win32=false
isMobileDevice=true

Add information about file type to the version information.

PHP browscap.ini files, all three versions (lite, normal and full), have the following information in them:

[GJK_Browscap_Version]
Version=5020
Released=Mon, 29 Jul 2013 22:22:31 -0000

This is a nice feature added so you can call get_browser('GJK_Browscap_Version')->version and get the current version number.

However this feature does not differentiate between lite, normal and full size file. Which is a problem when one tries to make a script with embedded browscap, because one cannot, in an orderly fashion, retrieve the file type information.

Of course it's possible to get the file size or something like that, and treat that as an additional version sub-number, but that's hacking. It would be much nicer if you'd release 3 versions every time, for example 5012.1, 5021.2, 5021.3 or .l, .n, .f or something like that.

Repeated values in children

The Platform value is unnecessarily repeated in every agent declaration for Chromium.

Originally reported from #47
Using version 5021-rc1

Duplicated data

Version 5021-b9 contains a lot of duplicated data. Here's just a couple of examples from full_php_browscap.ini:

[Mozilla/5.0 (Mac OS X) AppleWebKit/* (KHTML, like Gecko)_Chrome/10._Safari/*]
Parent=Chrome 10.0
Platform="MacOSX"
Win32=false
Platform="MacOSX"
Win32=false

[Mozilla/5.0 (Windows NT 6.0_WOW64) AppleWebKit/_ (KHTML, like Gecko)_Chrome/10._Safari/*]
Parent=Chrome 10.0
Platform="WinVista"
Platform_Version=6.0
Platform_Description="Windows Vista"
Win32=false
Win64=true
Platform="WinVista"
Platform_Version=6.0
Platform_Description="Windows Vista"
Win32=false
Win64=true

Another thing: Is it good to have Platform for Windows 8.1 be "Win8.1"? At least according to Google "Win81" is more commonly used.

New agent: Blackberry 10 devices

Mobile Blackberry OS 10 includes a new browser. Here is the agent string for inclusion:

Mozilla/5.0 (BB10; Kbd) AppleWebKit/537.35+ (KHTML, like Gecko)

This one is from the Blackberry Q10 phone (which is why I suspect the "Kbd" appears - since the Q10 has a keyboard). The Z10 model has no keyboard so it might differ from the Q10 agent string.

UA's not recognized #2

Hello,

I finally got around logging the UA'S that are not recognized on the latest "full_php_browscap.ini". I logged for about 12 hours.

http://pastebin.com/M9SLqf6a

The list is very long. I will post them to a reply in this comment just encase if there is a issue with paste bin.

Opera User Agent

The following user agent is detected as a Chrome browser, but it is an Opera Browser that uses Chrome

Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36 OPR/18.0.1284.49

lite_php_browscap.ini does not have Parent entries.

lite_php_browscap.ini doesn't have parent entries for:

AOL 9.0/IE 5.5
BitTorrent Clients
Chimera
Chrome 6.0
Chrome 7.0
Chrome 8.0
Chrome 9.0
Dillo
Fennec 4.0
Fennec 5.0
Fennec 6.0
Fennec 7.0
Firefox 2.0
Flock 1.0
Flock 2.0
Flock 3.0
Google Code
IBrowse
Internet Archive
Lotus Notes 5.0
Lotus Notes 6.0
Lunascape 5.0
Lunascape 5.1
Lunascape 6.0
Lycos
Palemoon
SeaMonkey 1.0
SeaMonkey 1.1
SeaMonkey 2.1
Sleipnir

which results in incorrect, partial matches for browsers with those parent entries.

For example:

var_dump(get_browser('Mozilla/5.0 (Intel Mac OS X) AppleWebKit/123 (KHTML, like Gecko) Chrome/9.0 Safari/123'));

// returns
// ["parent"]=> string(10) "Chrome 9.0"
// ["platform"]=> string(6) "MacOSX"
// ["win32"]=> string(0) ""
var_dump(get_browser('Mozilla/5.0 (Intel Mac OS X) AppleWebKit/123 (KHTML, like Gecko) Chrome/10.0 Safari/123'));

// returns
// ["parent"]=> string(11) "Chrome 10.0"
// ["platform"]=> string(6) "MacOSX"
// ["win32"]=> string(0) ""
// ["comment"]=> string(11) "Chrome 10.0"
// ["browser"]=> string(6) "Chrome"
// ["version"]=> string(4) "10.0"
// ["majorver"]=> string(2) "10"
// ["minorver"]=> string(1) "0"
// ["frames"]=> string(1) "1"
// ["iframes"]=> string(1) "1"
// ["tables"]=> string(1) "1"
// ["cookies"]=> string(1) "1"
// ["javascript"]=> string(1) "1"
// ["javaapplets"]=> string(1) "1"
// ["cssversion"]=> string(1) "3"
// ["platform_version"]=> string(7) "unknown"
// ["alpha"]=> string(0) ""
// ["beta"]=> string(0) ""
// ["win16"]=> string(0) ""
// ["win64"]=> string(0) ""
// ["backgroundsounds"]=> string(0) ""
// ["vbscript"]=> string(0) ""
// ["activexcontrols"]=> string(0) ""
// ["ismobiledevice"]=> string(0) ""
// ["issyndicationreader"]=> string(0) ""
// ["crawler"]=> string(0) ""
// ["aolversion"]=> string(1) "0"

I understand it's a light version, but even if you'd like to skip all those parameters for browsers with those parents, don't do it by not including the parent section. It's a reasonable assumption that the parent section should always exist in the file. So please, either restore those parent entries in full or just restore them as empty sections.

While it apparently doesn't break get_browser() it does break phpbrowscap and may break any number of other parsers.

Android Firefox/26.0 recognized as ismobiledevice = 0 ?

This is my first foray into browscap (I'm using the Drupal Module which is currently at 5020).

The full useragent string is:
Mozilla/5.0 (Android; Mobile; rv:26.0) Gecko/26.0 Firefox/26.0

.....yet this?
[ismobiledevice] => 0

Odd, no?

PS3 platform identification

Looks like we are identifying PS3 platform as "WAP".

Hi,
The platform for the Playstation parent class is set to WAP. Anybody know the origins of that?

Also, the Playstation 2 child class is the only one to override the platform value ("Linux"). I would have liked to put "CellOS" as the platform for Playstation 3 (the browser is already set to Sony PS3). Then we'll need a new class for the PS4 when that comes out...

.einar

From: https://groups.google.com/forum/#!topic/browscap/1vlGOvYsxSU

UA's not recognized

Hello,

Here is a list of UA's that are not recognized using the BETA "full_php_browscap.ini" I logged this for about 5 minutes on my site.

http://pastebin.com/W1st22E0

Requested # is how many unique people have that UA
UA is the full user agent.

Keep in mind this was only 5 minutes of logging this will help a lot once added then I can re log again.

Repeated information in the ini file.

While comparing standard versions ini files, 5020 release and 5021-b7, I've noticed that the beta file has some information unnecessarily repeated, and thus making the file size bigger without reason (unless I'm missing something?).

Example:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Android Browser 3.0

[Android Browser 3.0]
Parent=DefaultProperties
Comment="Android Browser 3.0"
Browser="Android"
Version=3.0
MajorVer=3
MinorVer=0
Platform="Android"
Frames=true
IFrames=true
Tables=true
Cookies=true
JavaScript=true
isMobileDevice=true
CssVersion=3

[Mozilla/5.0 (Linux*Android 1.0*)*AppleWebKit/*(*KHTML, like Gecko*)*Version/3.0*Safari/*]
Parent=Android Browser 3.0
Platform="Android"
Platform_Version=1.0
Win32=false
isMobileDevice=true

[Mozilla/5.0 (Linux*Android 1.1*)*AppleWebKit/*(*KHTML, like Gecko*)*Version/3.0*Safari/*]
Parent=Android Browser 3.0
Platform="Android"
Platform_Version=1.1
Win32=false
isMobileDevice=true

[*Mozilla/5.0 (Linux*Android 4.1*)*AppleWebKit/*(*KHTML, like Gecko*)*Version/3.0*Safari/*]
Parent=Android Browser 3.0
Platform="Android"
Platform_Version=4.1
Win32=false
isMobileDevice=true

Since all the entries here have parent = "Android Browser 3.0" then there is no need to repeat "isMobileDevice" and "Platform". Also "Win32" should be moved to the parent entry.

This is not the only place where information is repeated. In my opinion that should be eliminated automatically when creating the file.

Firefox 3.6.23 on MacOS 10.5 (PowerPC) erroneously detected as Mozilla 1.9

The new beta version of the Lite_PHP_BrowsCapINI considers the following User Agent string as coming from a Mozilla 1.9 browser:
"Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.2.23) Gecko/20110920 Firefox/3.6.23"

In the old release version from http://tempdownloads.browserscap.com/stream.php?Lite_PHP_BrowsCapINI it used to be correctly identified as Firefox 3.6.

Browscap version that shows the problem:
[GJK_Browscap_Version]
Version=5021-b7
Released=Sat, 02 Nov 2013 18:57:52 -0400

Here are the browscap-data as I received them from my colleague:

[browser_name_regex] => §^mozilla/5\.0 \(macintosh; .; .*mac os x.*; .*rv:1\.9.*\) gecko/.*$§
[browser_name_pattern] => Mozilla/5.0 (Macintosh; ?; *Mac OS X*; *rv:1.9*) Gecko/*
[parent] => Mozilla 1.9
[platform] => MacOSX
[win32] => 
[comment] => Mozilla 1.9
[browser] => Mozilla
[version] => 1.9
[majorver] => 1
[minorver] => 9
[frames] => 1
[iframes] => 1
[tables] => 1
[cookies] => 1
[javascript] => 1
[javaapplets] => 1
[cssversion] => 2
[platform_version] => unknown
[alpha] => 
[beta] => 
[win16] => 
[win64] => 
[backgroundsounds] => 
[vbscript] => 
[activexcontrols] => 
[ismobiledevice] => 
[issyndicationreader] => 
[crawler] => 
[aolversion] => 0

Chrome on iOS

Hi guys,

It seems that data for Chrome for iOS no includes platform version. I had the following two user-agents in a regression test from when I submitted PR #18:

Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) CriOS/28.0.1500.16 Mobile/11A4449d Safari/8536.25
Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_2 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) CriOS/30.0.1599.16 Mobile/11A501 Safari/8536.25

They were reporting platform version as 7.0, but now it is unknown (0.0). I'm happy to submit a PR for this, but I wasn't sure if it was intentional?

PHP get_browser() doesn't match browsers with '+' (plus sign).

PHP get_browser() doesn't match any browsers that contain + in the match pattern.

A fragment of php_browscap.ini:

[GJK_Browscap_Version]
Version=5020
Released=Mon, 29 Jul 2013 22:22:31 -0000

[Mozilla/5.0 (compatible; AhrefsBot/*; +http://ahrefs.com/robot/)]
Parent=Search Engines
Browser="AhrefsBot"

However a user agent Mozilla/5.0 (compatible; AhrefsBot/5.0; +http://ahrefs.com/robot/) doesn't match anything when used in get_browser().

See the original post: https://groups.google.com/forum/#!topic/browscap/s9zGyRBIvK0

Merge standard and full version of the file.

In my tests https://github.com/quentin389/ua-speed-tests I only see a very small performance difference between using php_browscap.ini and full_php_browscap.ini. Perhaps there is no reason to keep both versions if the time differences are that small?

Browscap execution time can be separated into two most important parts:

  • loading the data into memory
  • executing regular expressions

The time to execute regular expressions doesn't change at all between those two file versions, because full version only adds new properties, not new matches.

The file size and the data size increases in the full version but not that much. Hence only small execution time differences.

Feature: Create UA match "grep" script

Create a grep-like command in Browscap to process a text file given in an input parameter with UAs separated on newlines, and check them all. If any are "unidentified", output them, If they are successfully identified, don't output them (or vice versa). For example:

source-ua-list.txt

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
Mozilla/5.0 (Windows NT 6.1; rv:25.0) Gecko/20100101 Firefox/25.0
Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)

Example output:

$ bin/browscap grep --unmatched source-ua-list.txt
Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)
$ bin/browscap grep --matched source-ua-list.txt
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
Mozilla/5.0 (Windows NT 6.1; rv:25.0) Gecko/20100101 Firefox/25.0
$

What's the point of this? To run this over a list to narrow it down each time, it'll be a bit like a grep that shows unmatched UAs, hence the command name "grep".

Start using Semantic Versioning

https://packagist.org/about
http://semver.org/

The current "version" scheme (stable 5020, beta 5021) does not use Semantic Versioning (or even a real comprehensible versioning scheme).

I propose using Semantic versioning to replace what would be 5022 with 1.0.0, so:

  • 5020 => stays same
  • 5021 => stays same
  • 5022 => 1.0.0+5022 (if no code changes)
  • 5023 => 1.0.1+5023 (if no code changes)
  • 5024 => 1.0.2+5024 (if no code changes)
  • 5025 => 1.1.0+5025 (if non-BC breaking code changes)

This allows packagist to easily pick up version numbers and whatnot.

Edit: revised suggested version numbers based on discussion

Chrome Mobile 26.0.1410.58

  • | PropertyName | Chrome Mobile 26.0.1410.58
  • | Browser | Chrome Mobile
  • | Version | 26.0.1410.58
  • | MajorVer | 26
  • | MinorVer | 0
  • | Platform | Android
  • | PlatformVer | 4.2.2
  • | PlatformDesc | Android Jelly Bean
  • | Alpha | 0
  • | Beta | 0
  • | Frames | 1
  • | IFrames | 1
  • | Tables | 1
  • | Cookies | 1
  • | BackgroundSounds | 1
  • | Javascript | 1
  • | VBScript | 1
  • | JavaApplets | 1
  • | ActiveXControls | 0
  • | isMobileDevice | 1
  • | isSyndicationReader * | 1
  • | Crawler | 0
  • | CssVersion | 3
  • | DeviceName | Nexus 4 Build/JDQ39
  • | DeviceMaker | LG
  • | RenderingEngineName * | AppleWebKit
  • | RenderingEngineVer * | 537.31
  • | RenderingEngineDesc * | Open source application framework ver. 537.31

Issues in version 5021-rc1

  1. Firefox 24.0 appears two times in full_php_browscap.ini. Also the definitions are in a weird order, other browser definitions are in the middle of Firefox versions.
  2. Many user agent patterns contain two consecutive asterisk characters. I wonder if just one would be enough?
  3. Windows 8.1 is missing in many definitions, e.g. Chrome, Qt Generic and other Qt versions (they are missing also Windows 8), MS Outlook 2010 and 2013 (missing also Windows 8), Windows Live Mail (missing also Windows 8), Safari 2.0 and 3.0, Opera Generic and all Opera versions < 15.0, all Firefox versions, and so forth.
  4. The Platform value is unnecessarily repeated in every agent declaration for Chromium.

Firefox 24, IE11

IE11
Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko

Firefox
Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0

(Windows NT 6.3 is for Win8.1)

Missing UA - Chrome 30 on Windows 8.1

Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36

Should be identified as Chrome 30 on Windows 8.1. For some reason this is not.

Reported by @Shamilik

Opera, Maxthon, YaBrowser

All this browsers now is detected as Chrome (actualy they are besed on chrome/blink engine), but they are quite popular so I think this would be great to add support for detecting those browsers...

Opera v15+
Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36 OPR/16.0.1196.62

Maxthon v4+
Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Maxthon/4.1.2.4000 Chrome/26.0.1410.43 Safari/537.1

YaBrowser v1+
Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 YaBrowser/1.7.1364.21027 Safari/537.22

PHP get_browser() matches browser string with names only - that shouldn't happen.

A fragment of `php_browscap.ini':

[GJK_Browscap_Version]
Version=5020
Released=Mon, 29 Jul 2013 22:22:31 -0000

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; WebTV/MSNTV

[WebTV]
Parent=DefaultProperties
Comment="WebTV/MSNTV"
Browser="WebTV/MSNTV"
Platform="WebTV"
Frames=true
IFrames=true
Tables=true
Cookies=true

[Mozilla/3.0 WebTV/1.*(compatible; MSIE 2.0)]
Parent=WebTV
Version=1.0
MajorVer=1
MinorVer=0

[Mozilla/4.0 WebTV/2.0*(compatible; MSIE 3.0)]
Parent=WebTV
Version=2.0
MajorVer=2
MinorVer=0

[Mozilla/4.0 WebTV/2.1*(compatible; MSIE 3.0)]
Parent=WebTV
Version=2.1
MajorVer=2
MinorVer=1

[Mozilla/4.0 WebTV/2.2*(compatible; MSIE 3.0)]
Parent=WebTV
Version=2.2
MajorVer=2
MinorVer=2

[Mozilla/4.0 WebTV/2.3*(compatible; MSIE 3.0)]
Parent=WebTV
Version=2.3
MajorVer=2
MinorVer=3

[Mozilla/4.0 WebTV/2.4*(compatible; MSIE 3.0)]
Parent=WebTV
Version=2.4
MajorVer=2
MinorVer=4

[Mozilla/4.0 WebTV/2.5*(compatible; MSIE 4.0)]
Parent=WebTV
Version=2.5
MajorVer=2
MinorVer=5
CssVersion=1

[Mozilla/4.0 WebTV/2.6*(compatible; MSIE 4.0)]
Parent=WebTV
Version=2.6
MajorVer=2
MinorVer=6
CssVersion=1

[Mozilla/4.0 WebTV/2.7*(compatible; MSIE 4.0)]
Parent=WebTV
Version=2.7
MajorVer=2
MinorVer=7
CssVersion=1

[Mozilla/4.0 WebTV/2.8*(compatible; MSIE 4.0)]
Parent=WebTV
Version=2.8
MajorVer=2
MinorVer=8
VBScript=true
CssVersion=1

[Mozilla/4.0 WebTV/2.9*(compatible; MSIE 4.0)]
Parent=WebTV
Version=2.9
MajorVer=2
MinorVer=9
VBScript=true
CssVersion=1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Amaya

As you can see from this information the strings that match should be Mozilla/.... But what get_browser() does is that it also matches a string: WebTV which is really really lame.

Such user agent doesn't exist, unless someone just randomly types it.

I don't know if that's also a problem in other implementations of browscap, but it may be, because the problem lies within the construction of the ini files - you put the match strings in the section headers, but sometimes the section headers are just headers, nothing more, and should not be matched.

From what I've seen, a good check whether a match should be performed or not is presence of Comment. If there is a comment then it's just a section name, if there is no comment then it's a real match.

This error is populated, in the same form, to GaretJax Browscap PHP class.

Feature: Ability to specify the build path as an option

At the moment, the "build" path is hardcoded to ./build. This should be changed to be a command option, with the default being ./build. This allows us to generate files to different places should we need to.

Example use case
If we want to do an "integration test" (as in #23), and test a set of UA strings identify correctly, we need to be able to build the INI files into a temporary location (i.e. /tmp) and load them from there (by setting phpbrowscap\Browscap->localFile to the /tmp/bcaptest/php_browscap.ini) to check that the UA strings identify correctly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.