Skip to content

Commit 63dedd3

Browse files
committed
Restrict possible values for seoOp variable
1 parent dd77986 commit 63dedd3

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

seo.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,18 @@
1414

1515
include '../../mainfile.php';
1616

17-
if (empty($_GET['seoOp']))
17+
$seoMap = array(
18+
'category' => 'category.php',
19+
'faq' => 'faq.php',
20+
'print' => 'print.php'
21+
);
22+
23+
if(array_key_exists($_GET['seoOp'], $seoMap) || $_GET['seoOp'] = '')
24+
{
25+
$safe_seoOp = $_GET['seoOp'];
26+
};
27+
28+
if (empty($safe_seoOp))
1829
{
1930
// SEO mode is path-info
2031
/*
@@ -30,27 +41,21 @@
3041
// $seoArg = substr($data[1], strlen($seoOp) + 1);
3142
}
3243

33-
$seoMap = array(
34-
'category' => 'category.php',
35-
'faq' => 'faq.php',
36-
'print' => 'print.php'
37-
);
38-
39-
if (! empty($_GET['seoOp']) && ! empty($seoMap[$_GET['seoOp']]))
44+
if (! empty($safe_seoOp) && ! empty($seoMap[$safe_seoOp]))
4045
{
4146
// module specific dispatching logic, other module must implement as
4247
// per their requirements.
43-
$newUrl = '/modules/imfaq/' . $seoMap[$_GET['seoOp']];
48+
$newUrl = '/modules/imfaq/' . $seoMap[$safe_seoOp];
4449
if (substr($newUrl,-4) != '.php'){
4550
$newUrl .= '.php';
4651
}
4752

48-
$newUrl = str_ireplace('http://'.$_SERVER['SERVER_NAME'],'',ICMS_URL.$newUrl);
53+
$newUrl = str_ireplace('http://'.$_SERVER['SERVER_NAME'],'',ICMS_URL.$newUrl);
4954

5055
$_ENV['PHP_SELF'] = $newUrl;
5156
$_SERVER['SCRIPT_NAME'] = $newUrl;
5257
$_SERVER['PHP_SELF'] = $newUrl;
53-
switch ($_GET['seoOp']) {
58+
switch ($safe_seoOp) {
5459
case 'category':
5560
$_SERVER['REQUEST_URI'] = $newUrl . '?short_url=' . $_GET['seoArg'];
5661
$_GET['short_url'] = $_GET['seoArg'];
@@ -61,9 +66,7 @@
6166
$_SERVER['REQUEST_URI'] = $newUrl . '?short_url=' . $_GET['seoArg'];
6267
$_GET['short_url'] = $_GET['seoArg'];
6368
}
64-
include($_GET['seoOp'] . ".php");
69+
include($safe_seoOp . ".php");
6570
}
6671

6772
exit;
68-
69-
?>

0 commit comments

Comments
 (0)