Skip to content

Commit 30b0025

Browse files
committedSep 14, 2017
Added some more protection against possible XSS attacks
1 parent 169bdde commit 30b0025

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed
 

‎phpmyfaq/admin/configuration.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@
4646
// Set the new values
4747
$forbiddenValues = ['{', '}', '$'];
4848
$newConfigValues = [];
49-
$escapeValues = ['main.contactInformations', 'main.customPdfHeader', 'main.customPdfFooter'];
49+
$escapeValues = [
50+
'main.contactInformations',
51+
'main.customPdfHeader',
52+
'main.customPdfFooter',
53+
'main.titleFAQ'
54+
];
5055

5156
// Special checks
5257
if (isset($editData['edit']['main.enableMarkdownEditor'])) {
@@ -58,7 +63,7 @@
5863
$newConfigValues[$key] = str_replace($forbiddenValues, '', $value);
5964
// Escape some values
6065
if (isset($escapeValues[$key])) {
61-
$newConfigValues[$key] = PMF_String::htmlspecialchars($value, ENT_HTML5);
66+
$newConfigValues[$key] = PMF_String::htmlspecialchars($value, ENT_QUOTES);
6267
}
6368
$keyArray = array_values(explode('.', $key));
6469
$newConfigClass = array_shift($keyArray);

‎phpmyfaq/inc/PMF/Faq.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,7 @@ public function getRecordTitle($id)
16021602

16031603
if ($this->_config->getDb()->numRows($result) > 0) {
16041604
while ($row = $this->_config->getDb()->fetchObject($result)) {
1605-
$question = $row->question;
1605+
$question = PMF_String::htmlspecialchars($row->question);
16061606
}
16071607
} else {
16081608
$question = $this->pmf_lang['no_cats'];

‎phpmyfaq/index.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,11 @@
479479

480480
$tplMainPage = array(
481481
'msgLoginUser' => $user->isLoggedIn() ? $user->getUserData('display_name') : $PMF_LANG['msgLoginUser'],
482-
'title' => $faqConfig->get('main.titleFAQ').$title,
482+
'title' => PMF_String::htmlspecialchars($faqConfig->get('main.titleFAQ').$title),
483483
'baseHref' => $faqSystem->getSystemUri($faqConfig),
484484
'version' => $faqConfig->get('main.currentVersion'),
485-
'header' => str_replace('"', '', $faqConfig->get('main.titleFAQ')),
486-
'metaTitle' => str_replace('"', '', $faqConfig->get('main.titleFAQ').$title),
485+
'header' => PMF_String::htmlspecialchars(str_replace('"', '', $faqConfig->get('main.titleFAQ'))),
486+
'metaTitle' => PMF_String::htmlspecialchars(str_replace('"', '', $faqConfig->get('main.titleFAQ').$title)),
487487
'metaDescription' => $metaDescription,
488488
'metaKeywords' => $keywords,
489489
'metaPublisher' => $faqConfig->get('main.metaPublisher'),

‎phpmyfaq/main.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@
7777
'index',
7878
'breadcrumb',
7979
[
80-
'breadcrumbHeadline' => $faqConfig->get('main.titleFAQ')
80+
'breadcrumbHeadline' => PMF_String::htmlspecialchars($faqConfig->get('main.titleFAQ'))
8181
]
8282
);

0 commit comments

Comments
 (0)
Please sign in to comment.