PHP_SELF 를 이용한 XSS 취약점 수정
This commit is contained in:
@ -2881,7 +2881,7 @@ function clean_query_string($query, $amp=true)
|
||||
$q = array();
|
||||
|
||||
foreach($out as $key=>$val) {
|
||||
$key = trim($key);
|
||||
$key = strip_tags(trim($key));
|
||||
$val = trim($val);
|
||||
|
||||
switch($key) {
|
||||
@ -2953,4 +2953,38 @@ function clean_query_string($query, $amp=true)
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
function get_device_change_url()
|
||||
{
|
||||
$p = parse_url(G5_URL);
|
||||
$href = $p['scheme'].'://'.$p['host'];
|
||||
if(isset($p['port']) && $p['port'])
|
||||
$href .= ':'.$p['port'];
|
||||
$href .= $_SERVER['SCRIPT_NAME'];
|
||||
|
||||
$q = array();
|
||||
$device = 'device='.(G5_IS_MOBILE ? 'pc' : 'mobile');
|
||||
|
||||
if($_SERVER['QUERY_STRING']) {
|
||||
foreach($_GET as $key=>$val) {
|
||||
if($key == 'device')
|
||||
continue;
|
||||
|
||||
$key = strip_tags($key);
|
||||
$val = strip_tags($val);
|
||||
|
||||
if($key && $val)
|
||||
$q[$key] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($q)) {
|
||||
$query = http_build_query($q, '', '&');
|
||||
$href .= '?'.$query.'&'.$device;
|
||||
} else {
|
||||
$href .= '?'.$device;
|
||||
}
|
||||
|
||||
return $href;
|
||||
}
|
||||
?>
|
||||
@ -25,30 +25,8 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if(G5_DEVICE_BUTTON_DISPLAY && G5_IS_MOBILE) {
|
||||
$seq = 0;
|
||||
$p = parse_url(G5_URL);
|
||||
$href = $p['scheme'].'://'.$p['host'];
|
||||
if(isset($p['port']) && $p['port'])
|
||||
$href .= ':'.$p['port'];
|
||||
$href .= $_SERVER['PHP_SELF'];
|
||||
if($_SERVER['QUERY_STRING']) {
|
||||
$sep = '?';
|
||||
foreach($_GET as $key=>$val) {
|
||||
if($key == 'device')
|
||||
continue;
|
||||
|
||||
$href .= $sep.$key.'='.$val;
|
||||
$sep = '&';
|
||||
$seq++;
|
||||
}
|
||||
}
|
||||
if($seq)
|
||||
$href .= '&device=pc';
|
||||
else
|
||||
$href .= '?device=pc';
|
||||
?>
|
||||
<a href="<?php echo $href; ?>" id="device_change">PC 버전으로 보기</a>
|
||||
if(G5_DEVICE_BUTTON_DISPLAY && G5_IS_MOBILE) { ?>
|
||||
<a href="<?php echo get_device_change_url(); ?>" id="device_change">PC 버전으로 보기</a>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
26
tail.php
26
tail.php
@ -38,30 +38,8 @@ if (G5_IS_MOBILE) {
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if(G5_DEVICE_BUTTON_DISPLAY && !G5_IS_MOBILE) {
|
||||
$seq = 0;
|
||||
$p = parse_url(G5_URL);
|
||||
$href = $p['scheme'].'://'.$p['host'];
|
||||
if(isset($p['port']) && $p['port'])
|
||||
$href .= ':'.$p['port'];
|
||||
$href .= $_SERVER['PHP_SELF'];
|
||||
if($_SERVER['QUERY_STRING']) {
|
||||
$sep = '?';
|
||||
foreach($_GET as $key=>$val) {
|
||||
if($key == 'device')
|
||||
continue;
|
||||
|
||||
$href .= $sep.$key.'='.strip_tags($val);
|
||||
$sep = '&';
|
||||
$seq++;
|
||||
}
|
||||
}
|
||||
if($seq)
|
||||
$href .= '&device=mobile';
|
||||
else
|
||||
$href .= '?device=mobile';
|
||||
?>
|
||||
<a href="<?php echo $href; ?>" id="device_change">모바일 버전으로 보기</a>
|
||||
if(G5_DEVICE_BUTTON_DISPLAY && !G5_IS_MOBILE) { ?>
|
||||
<a href="<?php echo get_device_change_url(); ?>" id="device_change">모바일 버전으로 보기</a>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user