|
30 | 30 | ******************************************************************/ |
31 | 31 |
|
32 | 32 | // Return without saving button |
33 | | -$return = empty($_GET['return']) ? '' : '<input type="button" value="Cancel" onclick="window.location=\'' . $_GET['return'] . '\'">'; |
34 | | -$returnField = empty($_GET['return']) ? '' : '<input type="hidden" value="' . $_GET['return'] . '" name="return">'; |
| 33 | +$return = empty($_GET['return']) ? '' : '<input type="button" value="Cancel" onclick="window.location=\'' . remove_html($_GET['return']) . '\'">'; |
| 34 | +$returnField = empty($_GET['return']) ? '' : '<input type="hidden" value="' . remove_html($_GET['return']) . '" name="return">'; |
| 35 | +$agent = empty($_SERVER['HTTP_USER_AGENT']) ? '' : htmlentities($_SERVER['HTTP_USER_AGENT']); |
35 | 36 |
|
36 | 37 | // Quote strings |
37 | | -function q($value) { |
| 38 | +function escape_single_quotes($value) { |
38 | 39 | return str_replace("'", "\'", $value); |
39 | 40 | } |
| 41 | +function remove_html($x) { |
| 42 | + $x = preg_replace('#"#', '', $x); |
| 43 | + $x = preg_replace("#'#", '', $x); |
| 44 | + $x = preg_replace('#<#', '', $x); |
| 45 | + $x = preg_replace('#>#', '', $x); |
| 46 | + $x = preg_replace('#\\\\#', '', $x); |
| 47 | + return $x; |
| 48 | +} |
40 | 49 |
|
41 | 50 | // Get existing values |
42 | 51 | $browser = $_SESSION['custom_browser']; |
43 | 52 |
|
44 | | -$currentUA = q($browser['user_agent']); |
| 53 | +$currentUA = escape_single_quotes($browser['user_agent']); |
45 | 54 | $realReferrer = $browser['referrer'] == 'real' ? 'true' : 'false'; |
46 | | -$customReferrer = $browser['referrer'] == 'real' ? '' : q($browser['referrer']); |
| 55 | +$customReferrer = $browser['referrer'] == 'real' ? '' : escape_single_quotes($browser['referrer']); |
47 | 56 |
|
48 | 57 | echo <<<OUT |
49 | 58 | <script type="text/javascript"> |
@@ -141,7 +150,7 @@ function clearRealReferrer() { |
141 | 150 | <option value="Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; HTC Vision Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1">Android 2.3.5</option> |
142 | 151 | <option value="Mozilla/5.0 (BlackBerry; U; BlackBerry 9850; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.115 Mobile Safari/534.11+">Blackberry</option> |
143 | 152 | <option value="Opera/9.80 (J2ME/MIDP; Opera Mini/9.80 (S60; SymbOS; Opera Mobi/23.348; U; en) Presto/2.5.25 Version/10.54">Symbian with Opera Mini</option> |
144 | | - <option value="{$_SERVER['HTTP_USER_AGENT']}"> - Current/Real</option> |
| 153 | + <option value="{$agent}"> - Current/Real</option> |
145 | 154 | <option value=""> - None</option> |
146 | 155 | <option value="custom"> - Custom...</option> |
147 | 156 | </select> |
|
0 commit comments