From aaa6bcb61a4c7d90cf1d5a57ccb4b414ed2e94fc Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Wed, 10 Feb 2016 14:23:57 +0800 Subject: [PATCH] MDL-48307 mod_wiki: protect [edit] section link from nwiki parser --- mod/wiki/parser/markups/wikimarkup.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mod/wiki/parser/markups/wikimarkup.php b/mod/wiki/parser/markups/wikimarkup.php index 3e1efc0fd42..873b39fb76f 100644 --- a/mod/wiki/parser/markups/wikimarkup.php +++ b/mod/wiki/parser/markups/wikimarkup.php @@ -178,16 +178,18 @@ abstract class wiki_markup_parser extends generic_parser { */ protected function generate_header($text, $level) { - $text = trim($text); + $toctext = $text = trim($text); if (!$this->pretty_print && $level == 1) { - $text .= ' ' . parser_utils::h('a', '['.get_string('editsection', 'wiki').']', - array('href' => "edit.php?pageid={$this->wiki_page_id}§ion=" . urlencode($text), - 'class' => 'wiki_edit_section')); + $editlink = '[' . get_string('editsection', 'wiki') . ']'; + $url = array('href' => "edit.php?pageid={$this->wiki_page_id}§ion=" . urlencode($text), + 'class' => 'wiki_edit_section'); + $text .= ' ' . parser_utils::h('a', $this->protect($editlink), $url); + $toctext .= ' ' . parser_utils::h('a', $editlink, $url); } if ($level <= $this->maxheaderdepth) { - $this->toc[] = array($level, $text); + $this->toc[] = array($level, $toctext); $num = count($this->toc); $text = parser_utils::h('a', "", array('name' => "toc-$num")) . $text; }