Making WordPress.org


Ignore:
Timestamp:
10/16/2017 10:35:14 PM (6 years ago)
Author:
coffee2code
Message:

Browse Happy API: Add inline documentation for regexes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/core/browse-happy/1.0/parse.php

    r6037 r6038  
    137137    // Identify platform/OS in user-agent string.
    138138    if ( preg_match(
    139         '/^.+?(?P<platform>Windows Phone( OS)?|Symbian|SymbOS|Android|iPhone|iPad|Windows|Linux|Macintosh|FreeBSD|OpenBSD|SunOS|RIM Tablet OS|PlayBook)(?: (NT|amd64|armv7l|zvav))*(?: [ix]?[0-9._]+(\-[0-9a-z\.\-]+)?)*(;|\))/im',
     139        '/^.+?'                                                   // Possibly starts with one or more characters
     140        . '(?P<platform>'                                         // Capture subpattern matches into 'platform' array
     141        .     'Windows Phone( OS)?|Symbian|SymbOS|Android|iPhone' // Platform tokens
     142        .     '|iPad|Windows|Linux|Macintosh|FreeBSD|OpenBSD'     // More platform tokens
     143        .     '|SunOS|RIM Tablet OS|PlayBook'                     // More platform tokens
     144        . ')'
     145        . '(?:'
     146        .     ' (NT|amd64|armv7l|zvav)'                           // Possibly followed by specific modifiers/specifiers
     147        . ')*'
     148        . '(?:'
     149        .     ' [ix]?[0-9._]+'                                    // Possibly followed by architecture modifier (e.g. x86_64)
     150        .     '(\-[0-9a-z\.\-]+)?'                                // Possibly followed by a hypenated version number
     151        . ')*'
     152        . '(;|\))'                                                // Ending in a semi-colon or close parenthesis
     153        . '/im',                                                  // Case insensitive, multiline
    140154        $user_agent,
    141155        $regs
     
    146160    // Find tokens of interest in user-agent string.
    147161    preg_match_all(
    148         '%(?P<name>Opera Mini|Opera|OPR|Edge|UCBrowser|UCWEB|QQBrowser|SymbianOS|Symbian|S40OviBrowser|Trident|Silk|Konqueror|PaleMoon|Puffin|SeaMonkey|Vivaldi|Camino|Chromium|Kindle|Firefox|SamsungBrowser|(?:Mobile )?Safari|NokiaBrowser|MSIE|RockMelt|AppleWebKit|Chrome|IEMobile|Version)(?:[/ ])(?P<version>[0-9.]+)%im',
     162          '%(?P<name>'                                            // Capture subpattern matches into the 'name' array
     163        .     'Opera Mini|Opera|OPR|Edge|UCBrowser|UCWEB'         // Browser tokens
     164        .     '|QQBrowser|SymbianOS|Symbian|S40OviBrowser'        // More browser tokens
     165        .     '|Trident|Silk|Konqueror|PaleMoon|Puffin'           // More browser tokens
     166        .     '|SeaMonkey|Vivaldi|Camino|Chromium|Kindle|Firefox' // More browser tokens
     167        .     '|SamsungBrowser|(?:Mobile )?Safari|NokiaBrowser'   // More browser tokens
     168        .     '|MSIE|RockMelt|AppleWebKit|Chrome|IEMobile'        // More browser tokens
     169        .     '|Version'                                          // Version token
     170        . ')'
     171        . '(?:'
     172        .     '[/ ]'                                              // Forward slash or space
     173        . ')'
     174        . '(?P<version>'                                          // Capture subpattern matches into 'version' array
     175        .     '[0-9.]+'                                           // One or more numbers and/or decimal points
     176        . ')'
     177        . '%im',                                                  // Case insensitive, multiline
    149178        $user_agent,
    150179        $result,
Note: See TracChangeset for help on using the changeset viewer.