From 3e5c0174862a0a526252399c681bafc51eedc275 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 25 Jul 2019 17:22:35 +0200 Subject: [PATCH] mediawiki: make docs include plugin tags robuster for new MW version Some (new) mediawiki versions can convert '<' and '>' to '<' or '>', this resulted in a situation where our encoded tag did not get detected by the decode logic, and thus a visitor only saw something like the following: > <--- @PVEDOCHACK@ > PCEtLSBhc2NpaWRvYyBIRUFERVIgLS0+DQo8c2NyaXB0IHR5..... > @PVEDOCHACK@ --> The word "HACK" was a bit unfortunate too, as it could be interpreted as in the docs got hacked, by unknowing people. So change that too to 'PVEDOCS_BASE64' Signed-off-by: Thomas Lamprecht --- debian/tree/pve-docs-mediawiki/pvedocs-include.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/debian/tree/pve-docs-mediawiki/pvedocs-include.php b/debian/tree/pve-docs-mediawiki/pvedocs-include.php index 07ccf1c..f8d62d4 100644 --- a/debian/tree/pve-docs-mediawiki/pvedocs-include.php +++ b/debian/tree/pve-docs-mediawiki/pvedocs-include.php @@ -28,7 +28,7 @@ function efPvedocsParserFunction_Setup(&$parser) { # similar code as in tag... function efPvedocsPostProcessFunction($parser, &$text) { $text = preg_replace_callback( - '/<--- @PVEDOCSHACK@ ([0-9a-zA-Z\\+\\/]+=*) @PVEDOCSHACK@ -->/sm', + '/-_- @PVEDOCS_BASE64@ ([0-9a-zA-Z\\+\\/]+=*) @PVEDOCS_BASE64@ -_-/sm', function ($m) { return base64_decode("$m[1]"); }, $text); @@ -66,7 +66,9 @@ function efPvedocsParserFunction_Render($parser, $param1 = '', $param2 = '') { $content = file_get_contents("/usr/share/pve-docs/$param1"); - $output = '<--- @PVEDOCSHACK@ '.base64_encode($content).' @PVEDOCSHACK@ -->'; + # do not use '<' or '>', it seems newer mediawiki converts it to '<' and '>' + # and then the regex for the decode in efPvedocsPostProcessFunction does not matches.. + $output = '-_- @PVEDOCS_BASE64@ '.base64_encode($content).' @PVEDOCS_BASE64@ -_-'; return array($output, 'noparse' => true, 'isHTML' => true); } -- 2.39.2