Codebase list libhttp-browserdetect-perl / 548476a
Tidy Andrew Moise 9 years ago
1 changed file(s) with 68 addition(s) and 67 deletion(s). Raw diff Collapse all Expand all
535535 $browser_tests->{ie} = 1;
536536
537537 if ( index( $ua, 'aol' ) != -1
538 || index( $ua, 'america online browser' ) != -1 ) {
538 || index( $ua, 'america online browser' ) != -1 ) {
539539 $browser_string = 'AOL Browser';
540540 $browser_tests->{aol} = 1;
541541 }
542 # Disabled for now -- need to figure out how to deal with version numbers
543 #elsif ( index ( $ua, 'acoobrowser' ) != -1 ) {
544 # $browser_string = 'Acoo Browser';
545 #}
546 #elsif ( index( $ua, 'avant' ) != -1 ) {
547 # $browser_string = 'Avant Browser';
548 #}
549 #elsif ( index( $ua, 'crazy browser' ) != -1 ) {
550 # $browser_string = 'Crazy Browser';
551 #}
552 #elsif ( index( $ua, 'deepnet explorer' ) != -1 ) {
553 # $browser_string = 'Deepnet Explorer';
554 #}
555 #elsif ( index( $ua, 'maxthon' ) != -1 ) {
556 # $browser_string = 'Maxthon';
557 #}
542
543 # Disabled for now -- need to figure out how to deal with version numbers
544 #elsif ( index ( $ua, 'acoobrowser' ) != -1 ) {
545 # $browser_string = 'Acoo Browser';
546 #}
547 #elsif ( index( $ua, 'avant' ) != -1 ) {
548 # $browser_string = 'Avant Browser';
549 #}
550 #elsif ( index( $ua, 'crazy browser' ) != -1 ) {
551 # $browser_string = 'Crazy Browser';
552 #}
553 #elsif ( index( $ua, 'deepnet explorer' ) != -1 ) {
554 # $browser_string = 'Deepnet Explorer';
555 #}
556 #elsif ( index( $ua, 'maxthon' ) != -1 ) {
557 # $browser_string = 'Maxthon';
558 #}
558559 }
559560 elsif ( index( $ua, "silk" ) != -1 ) {
560561
563564 $browser = 'silk';
564565 $browser_tests->{$browser} = 1;
565566 }
566 elsif ( index( $ua, "chrome/" ) != -1
567 || index( $ua, "crios" ) != -1 ) {
567 elsif (index( $ua, "chrome/" ) != -1
568 || index( $ua, "crios" ) != -1 ) {
568569
569570 # Browser is Chrome
570571
589590
590591 $browser_tests->{safari} = 1;
591592 $browser = 'safari';
592 if ( index( $ua, " mobile safari/" ) != -1
593 || index( $ua, "mobilesafari" ) != -1 )
594 {
593 if ( index( $ua, " mobile safari/" ) != -1
594 || index( $ua, "mobilesafari" ) != -1 ) {
595595 $browser_string = 'Mobile Safari';
596596 $browser_tests->{mobile_safari} = 1;
597597 }
707707 $browser_tests->{$browser} = 1;
708708 }
709709 elsif ( index( $ua, "dalvik" ) != -1 ) {
710 $browser = 'dalvik';
711 $browser_tests->{$browser} = 1;
710 $browser = 'dalvik';
711 $browser_tests->{$browser} = 1;
712712 }
713713 elsif ( index( $ua, "ucbrowser" ) != -1 ) {
714 $browser = 'ucbrowser';
715 $browser_tests->{$browser} = 1;
714 $browser = 'ucbrowser';
715 $browser_tests->{$browser} = 1;
716716 }
717717
718718 $self->{browser} = $browser;
828828 $r = 'altavista';
829829 }
830830 elsif ( index( $ua, "apache-httpclient" ) != -1 ) {
831 $r = 'apache';
831 $r = 'apache';
832832 }
833833 elsif ( index( $ua, "ask jeeves/teoma" ) != -1 ) {
834834 $r = 'askjeeves';
874874 $r = 'google';
875875 }
876876 elsif ( $ua =~ m{go.*package http} ) {
877 $r = 'golib';
878 $robot_tests->{lib} = 1;
877 $r = 'golib';
878 $robot_tests->{lib} = 1;
879879 }
880880 elsif ( index( $ua, "indy library" ) != -1 ) {
881881 $r = 'indy';
894894 $r = 'lycos';
895895 }
896896 elsif ( index( $ua, "mechanize" ) != -1 ) {
897 $r = 'rubylib';
898 $robot_tests->{lib} = 1;
897 $r = 'rubylib';
898 $robot_tests->{lib} = 1;
899899 }
900900 elsif ( index( $ua, "mj12bot/" ) != -1 ) {
901901 $r = 'mj12bot';
922922 elsif ( index( $ua, "yandeximages" ) != -1 ) {
923923 $r = 'yandeximages';
924924 }
925 elsif ( ($ua =~ m{^java} && !$self->{browser} )
925 elsif (( $ua =~ m{^java} && !$self->{browser} )
926926 || index( $ua, "jdk" ) != -1
927927 || index( $ua, "jakarta commons-httpclient" ) != -1
928928 || index( $ua, "google-http-java-client" ) != -1 ) {
930930 $robot_tests->{lib} = 1;
931931 }
932932
933 if ( $browser_tests->{applecoremedia}
934 || $browser_tests->{dalvik} )
935 {
933 if ( $browser_tests->{applecoremedia}
934 || $browser_tests->{dalvik} ) {
936935 $robot_tests->{lib} = 1;
937936 }
938937
958957 $self->{robot_fragment} = "search";
959958 $robot_tests->{robot} = 'unknown';
960959 }
961 elsif ( 0 && $self->{user_agent} =~ /([\w \/\.]+)\s*[\;\(]\s*\+http\:/i ) {
962 # Something followed by +http
963 $self->{robot_string} = $1;
964 $self->{robot_string} =~ s/^(.*?)\s*/$1/;
965 $robot_tests->{robot} = 'unknown';
960 elsif ( 0 && $self->{user_agent} =~ /([\w \/\.]+)\s*[\;\(]\s*\+http\:/i )
961 {
962 # Something followed by +http
963 $self->{robot_string} = $1;
964 $self->{robot_string} =~ s/^(.*?)\s*/$1/;
965 $robot_tests->{robot} = 'unknown';
966966 }
967967 else {
968968 # See if we have a simple fragment
10181018 $os_string = 'Win95';
10191019 $os_tests->{win95} = $os_tests->{win32} = 1;
10201020 }
1021 elsif ( index( $ua, "win 9x 4.90" ) != -1 # whatever
1022 || index( $ua, "windows me" ) != -1 )
1023 {
1021 elsif (
1022 index( $ua, "win 9x 4.90" ) != -1 # whatever
1023 || index( $ua, "windows me" ) != -1
1024 ) {
10241025 $os = "windows";
10251026 $os_string = 'WinME';
10261027 $os_tests->{winme} = $os_tests->{win32} = 1;
10311032 $os_string = 'Win98';
10321033 $os_tests->{win98} = $os_tests->{win32} = 1;
10331034 }
1034 elsif ( index( $ua, "windows 2000" ) != -1 ) {
1035 elsif ( index( $ua, "windows 2000" ) != -1 ) {
10351036 $os = "windows";
10361037 $os_string = 'Win2k';
10371038 $os_tests->{win2k} = $os_tests->{winnt} = $os_tests->{win32} = 1;
1038 }
1039 }
10391040 elsif ( index( $ua, "windows ce" ) != -1 ) {
10401041 $os = 'windows';
10411042 $os_string = 'WinCE';
10581059 }
10591060
10601061 if ( index( $ua, "nt" ) != -1 ) {
1061 if ( index( $ua, "nt 5.0" ) != -1
1062 || index( $ua, "nt5" ) != -1 )
1063 {
1062 if ( index( $ua, "nt 5.0" ) != -1
1063 || index( $ua, "nt5" ) != -1 ) {
10641064 $os = "windows";
10651065 $os_string = 'Win2k';
10661066 $os_tests->{win2k} = $os_tests->{winnt} = $os_tests->{win32} = 1;
14691469 $minor = $2;
14701470 $beta = $3;
14711471 }
1472 elsif ( $browser eq 'chrome' &&
1473 $ua =~ m{crios/(\d+)\.(\d+)([\d.]*)} )
1474 {
1472 elsif ($browser eq 'chrome'
1473 && $ua =~ m{crios/(\d+)\.(\d+)([\d.]*)} ) {
14751474 $major = $1;
14761475 $minor = $2;
14771476 $beta = $3;
18391838 $device_string = "BlackBerry $1";
18401839 }
18411840 elsif ( $self->{user_agent} =~ /android .*\; ([^;]*) build/i ) {
1842 if ( $device_tests->{tablet} ) {
1843 $device_string = "Android tablet ($1)";
1844 } else {
1845 $device_string = "Android ($1)";
1846 }
1841 if ( $device_tests->{tablet} ) {
1842 $device_string = "Android tablet ($1)";
1843 }
1844 else {
1845 $device_string = "Android ($1)";
1846 }
18471847 }
18481848 elsif ( $self->{user_agent}
18491849 =~ /\b((alcatel|huawei|lg|nokia|samsung|sonyericsson)[\w\-]*)\//i ) {
18651865 }
18661866
18671867 if ($device_string) {
1868 $self->{device_string} = $device_string;
1868 $self->{device_string} = $device_string;
18691869 }
18701870 }
18711871
23482348 ) {
23492349 $self->{robot_string} = $1;
23502350 $self->{robot_string} =~ s/ *$//; # Trim whitespace at end
2351 if ( $self->{user_agent} eq $self->{robot_string}
2352 && $self->{user_agent} =~ m{\/.*\/}
2353 && $self->{user_agent} =~ m{
2351 if (
2352 $self->{user_agent} eq $self->{robot_string}
2353 && $self->{user_agent} =~ m{\/.*\/}
2354 && $self->{user_agent} =~ m{
23542355 ([\w]* # Words before fragment
23552356 $fragment # Match the fragment
23562357 \/[\d\.]+ # Version
23572358 [\w]*) # Beta stuff
2358 }ix )
2359 {
2360 # We matched the whole string, but it seems to
2361 # make more sense as whitespace-separated
2362 # "thing/ver" tokens
2363 $self->{robot_string} = $1;
2364 }
2359 }ix
2360 ) {
2361 # We matched the whole string, but it seems to
2362 # make more sense as whitespace-separated
2363 # "thing/ver" tokens
2364 $self->{robot_string} = $1;
2365 }
23652366 }
23662367 }
23672368 return $self->{robot_string};