Debian Codegraph @

autotests/html/devicedetect.vcl.dark.html

raw
1 <!DOCTYPE html>
2 <html><head>
3 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
4 <title>devicedetect.vcl</title>
5 <meta name="generator" content="KF5::SyntaxHighlighting - Definition (Varnish Configuration Language) - Theme (Breeze Dark)"/>
6 </head><body style="background-color:#232629;color:#cfcfc2"><pre>
7 <span style="color:#7a7c7d;">#</span>
8 <span style="color:#7a7c7d;"># Copyright (c) 2016-2018 Varnish Cache project</span>
9 <span style="color:#7a7c7d;"># Copyright (c) 2012-2016 Varnish Software AS</span>
10 <span style="color:#7a7c7d;">#</span>
11 <span style="color:#7a7c7d;"># </span><span style="color:#3f8058;font-style:italic;">SPDX-License-Identifier:</span><span style="color:#3f8058;font-style:italic;"> </span><span style="color:#3f8058;font-style:italic;">BSD-2-Clause</span>
12 <span style="color:#7a7c7d;">#</span>
13 <span style="color:#7a7c7d;"># Redistribution and use in source and binary forms, with or without</span>
14 <span style="color:#7a7c7d;"># modification, are permitted provided that the following conditions</span>
15 <span style="color:#7a7c7d;"># are met:</span>
16 <span style="color:#7a7c7d;"># 1. Redistributions of source code must retain the above copyright</span>
17 <span style="color:#7a7c7d;"># notice, this list of conditions and the following disclaimer.</span>
18 <span style="color:#7a7c7d;"># 2. Redistributions in binary form must reproduce the above copyright</span>
19 <span style="color:#7a7c7d;"># notice, this list of conditions and the following disclaimer in the</span>
20 <span style="color:#7a7c7d;"># documentation and/or other materials provided with the distribution.</span>
21 <span style="color:#7a7c7d;">#</span>
22 <span style="color:#7a7c7d;"># THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND</span>
23 <span style="color:#7a7c7d;"># ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE</span>
24 <span style="color:#7a7c7d;"># IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
25 <span style="color:#7a7c7d;"># ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE</span>
26 <span style="color:#7a7c7d;"># FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span>
27 <span style="color:#7a7c7d;"># DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS</span>
28 <span style="color:#7a7c7d;"># OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)</span>
29 <span style="color:#7a7c7d;"># HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT</span>
30 <span style="color:#7a7c7d;"># LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY</span>
31 <span style="color:#7a7c7d;"># OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</span>
32 <span style="color:#7a7c7d;"># SUCH DAMAGE.</span>
33 <span style="color:#7a7c7d;">#</span>
34 <span style="color:#7a7c7d;"># detectdevice.vcl - regex based device detection for Varnish</span>
35 <span style="color:#7a7c7d;"># https://github.com/varnishcache/varnish-devicedetect/</span>
36 <span style="color:#7a7c7d;">#</span>
37 <span style="color:#7a7c7d;"># Original author: Lasse Karstensen &lt;[email protected]&gt;</span>
38
39 <span style="font-weight:bold;">sub</span> devicedetect {
40 <span style="font-weight:bold;">unset</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span>;
41 <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;pc&quot;</span>;
42
43 <span style="color:#7a7c7d;"># Handle that a cookie may override the detection alltogether.</span>
44 <span style="font-weight:bold;">if</span> (<span style="color:#0099ff;">req.http.Cookie</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)X-UA-Device-force&quot;</span>) {
45 <span style="color:#7a7c7d;">/* ;?? means zero or one ;, non-greedy to match the first. */</span>
46 <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#8e44ad;">regsub</span>(<span style="color:#0099ff;">req.http.Cookie</span>, <span style="color:#f44f4f;">&quot;(?i).*X-UA-Device-force=([^;]+);??.*&quot;</span>, <span style="color:#f44f4f;">&quot;\1&quot;</span>);
47 <span style="color:#7a7c7d;">/* Clean up our mess in the cookie header */</span>
48 <span style="font-weight:bold;">set</span> <span style="color:#0099ff;">req.http.Cookie</span> <span style="color:#27ae60;">=</span> <span style="color:#8e44ad;">regsuball</span>(<span style="color:#0099ff;">req.http.Cookie</span>, <span style="color:#f44f4f;">&quot;(^|; ) *X-UA-Device-force=[^;]+;? *&quot;</span>, <span style="color:#f44f4f;">&quot;\1&quot;</span>);
49 <span style="color:#7a7c7d;">/* If the cookie header is now empty, or just whitespace, unset it. */</span>
50 <span style="font-weight:bold;">if</span> (<span style="color:#0099ff;">req.http.Cookie</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;^ *$&quot;</span>) { <span style="font-weight:bold;">unset</span> <span style="color:#0099ff;">req.http.Cookie</span>; }
51 } <span style="font-weight:bold;">else</span> {
52 <span style="font-weight:bold;">if</span> (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;\(compatible; Googlebot-Mobile/2.1; \+http://www.google.com/bot.html\)&quot;</span> <span style="color:#27ae60;">||</span>
53 (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(Android|iPhone)&quot;</span> <span style="color:#27ae60;">&amp;&amp;</span> <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;\(compatible.?; Googlebot/2.1.?; \+http://www.google.com/bot.html&quot;</span>) <span style="color:#27ae60;">||</span>
54 (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(iPhone|Windows Phone)&quot;</span> <span style="color:#27ae60;">&amp;&amp;</span> <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;\(compatible; bingbot/2.0; \+http://www.bing.com/bingbot.htm&quot;</span>)) {
55 <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;mobile-bot&quot;</span>; }
56 <span style="font-weight:bold;">elsif</span> (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot&quot;</span> <span style="color:#27ae60;">||</span>
57 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)(baidu|jike|symantec)spider&quot;</span> <span style="color:#27ae60;">||</span>
58 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)pingdom&quot;</span> <span style="color:#27ae60;">||</span>
59 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)facebookexternalhit&quot;</span> <span style="color:#27ae60;">||</span>
60 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)scanner&quot;</span> <span style="color:#27ae60;">||</span>
61 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)slurp&quot;</span> <span style="color:#27ae60;">||</span>
62 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)(web)crawler&quot;</span>) {
63 <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;bot&quot;</span>; }
64 <span style="font-weight:bold;">elsif</span> (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)ipad&quot;</span>) { <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;tablet-ipad&quot;</span>; }
65 <span style="font-weight:bold;">elsif</span> (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)ip(hone|od)&quot;</span>) { <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;mobile-iphone&quot;</span>; }
66 <span style="color:#7a7c7d;">/* how do we differ between an android phone and an android tablet?</span>
67 <span style="color:#7a7c7d;"> http://stackoverflow.com/questions/5341637/how-do-detect-android-tablets-in-general-useragent */</span>
68 <span style="font-weight:bold;">elsif</span> (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)android.*(mobile|mini)&quot;</span>) { <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;mobile-android&quot;</span>; }
69 <span style="color:#7a7c7d;">// android 3/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.</span>
70 <span style="font-weight:bold;">elsif</span> (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)android 3&quot;</span>) { <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;tablet-android&quot;</span>; }
71 <span style="color:#7a7c7d;">/* Opera Mobile */</span>
72 <span style="font-weight:bold;">elsif</span> (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;Opera Mobi&quot;</span>) { <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;mobile-smartphone&quot;</span>; }
73 <span style="color:#7a7c7d;">// May very well give false positives towards android tablets. Suggestions welcome.</span>
74 <span style="font-weight:bold;">elsif</span> (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)android&quot;</span>) { <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;tablet-android&quot;</span>; }
75 <span style="font-weight:bold;">elsif</span> (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;PlayBook; U; RIM Tablet&quot;</span>) { <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;tablet-rim&quot;</span>; }
76 <span style="font-weight:bold;">elsif</span> (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;hp-tablet.*TouchPad&quot;</span>) { <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;tablet-hp&quot;</span>; }
77 <span style="font-weight:bold;">elsif</span> (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;Kindle/3&quot;</span>) { <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;tablet-kindle&quot;</span>; }
78 <span style="font-weight:bold;">elsif</span> (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;Touch.+Tablet PC&quot;</span> <span style="color:#27ae60;">||</span>
79 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;Windows NT [0-9.]+; ARM;&quot;</span> ) {
80 <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;tablet-microsoft&quot;</span>;
81 }
82 <span style="font-weight:bold;">elsif</span> (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;Mobile.+Firefox&quot;</span>) { <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;mobile-firefoxos&quot;</span>; }
83 <span style="font-weight:bold;">elsif</span> (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;^HTC&quot;</span> <span style="color:#27ae60;">||</span>
84 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;Fennec&quot;</span> <span style="color:#27ae60;">||</span>
85 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;IEMobile&quot;</span> <span style="color:#27ae60;">||</span>
86 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;BlackBerry&quot;</span> <span style="color:#27ae60;">||</span>
87 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;BB10.*Mobile&quot;</span> <span style="color:#27ae60;">||</span>
88 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;GT-.*Build/GINGERBREAD&quot;</span> <span style="color:#27ae60;">||</span>
89 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;SymbianOS.*AppleWebKit&quot;</span>) {
90 <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;mobile-smartphone&quot;</span>;
91 }
92 <span style="font-weight:bold;">elsif</span> (<span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)symbian&quot;</span> <span style="color:#27ae60;">||</span>
93 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)^sonyericsson&quot;</span> <span style="color:#27ae60;">||</span>
94 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)^nokia&quot;</span> <span style="color:#27ae60;">||</span>
95 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)^samsung&quot;</span> <span style="color:#27ae60;">||</span>
96 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)^lg&quot;</span> <span style="color:#27ae60;">||</span>
97 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)bada&quot;</span> <span style="color:#27ae60;">||</span>
98 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)blazer&quot;</span> <span style="color:#27ae60;">||</span>
99 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)cellphone&quot;</span> <span style="color:#27ae60;">||</span>
100 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)iemobile&quot;</span> <span style="color:#27ae60;">||</span>
101 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)midp-2.0&quot;</span> <span style="color:#27ae60;">||</span>
102 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)u990&quot;</span> <span style="color:#27ae60;">||</span>
103 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)netfront&quot;</span> <span style="color:#27ae60;">||</span>
104 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)opera mini&quot;</span> <span style="color:#27ae60;">||</span>
105 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)palm&quot;</span> <span style="color:#27ae60;">||</span>
106 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)nintendo wii&quot;</span> <span style="color:#27ae60;">||</span>
107 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)playstation portable&quot;</span> <span style="color:#27ae60;">||</span>
108 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)portalmmm&quot;</span> <span style="color:#27ae60;">||</span>
109 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)proxinet&quot;</span> <span style="color:#27ae60;">||</span>
110 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)windows\ ?ce&quot;</span> <span style="color:#27ae60;">||</span>
111 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)winwap&quot;</span> <span style="color:#27ae60;">||</span>
112 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)eudoraweb&quot;</span> <span style="color:#27ae60;">||</span>
113 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)htc&quot;</span> <span style="color:#27ae60;">||</span>
114 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)240x320&quot;</span> <span style="color:#27ae60;">||</span>
115 <span style="color:#0099ff;">req.http.User-Agent</span> <span style="color:#27ae60;">~</span> <span style="color:#f44f4f;">&quot;(?i)avantgo&quot;</span>) {
116 <span style="font-weight:bold;">set</span> <span style="color:#0099ff;font-style:italic;">req.http.X-UA-Device</span> <span style="color:#27ae60;">=</span> <span style="color:#f44f4f;">&quot;mobile-generic&quot;</span>;
117 }
118 }
119 }
120 </pre></body></html>