Skip to content

Commit 22f210c

Browse files
committed
[core] support HypCommon's CSRF protection (on Ajax editing)
1 parent 5c3245a commit 22f210c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

xoops_trust_path/modules/xpwiki/class/func/pukiwiki_func.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -3746,6 +3746,7 @@ function edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE, $optio
37463746
$nonconvert = (empty($this->vars['nonconvert']))? '' : '<input type="hidden" name="nonconvert" value="1" />';
37473747
$enc_hint = '<input type="hidden" name="encode_hint" value="' . $this->cont['PKWK_ENCODING_HINT'] . '" />'
37483748
. '<input type="hidden" name="charset" value="UTF-8" />';
3749+
$csrf_protect = isset($_SESSION['HYP_CSRF_TOKEN'])? '<input type="hidden" name="HypToken" value="'.htmlspecialchars($_SESSION['HYP_CSRF_TOKEN']).'" />' : '';
37493750
$attaches = '';
37503751
if ($s_id) {
37513752
$other_option = $template = $reading = $alias = $pageorder = '';
@@ -3756,7 +3757,7 @@ function edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE, $optio
37563757
$other_hide = (! $other_option_checked)? 'style="display:none;"' : '';
37573758
$other_hide_js = '';
37583759
} else {
3759-
$nonconvert = $ajax_submit = $ajax_cancel = $enc_hint = $other_hide = '';
3760+
$nonconvert = $ajax_submit = $ajax_cancel = $enc_hint = $other_hide = $csrf_protect = '';
37603761
$form_class = $popup? 'edit_form_ajax' : 'edit_form';
37613762
$ajax_cancel = $popup? ' onsubmit="window.parent.XpWiki.PopupHide();return false;"' : '';
37623763
$other_hide_js = (! $other_option_checked)? '<script type="text/javascript">$(\'xpwiki_edit_other\').style.display = \'none\';</script>' : '';
@@ -3794,6 +3795,7 @@ function edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE, $optio
37943795
</div>
37953796
$nonconvert
37963797
$enc_hint
3798+
$csrf_protect
37973799
$popup
37983800
<input type="hidden" name="cmd" value="edit" />
37993801
<input type="hidden" name="page" value="$s_page" />

0 commit comments

Comments
 (0)