diff options
author | petko <petko@524c5546-5005-0410-9a3e-e25e191bd360> | 2024-04-08 08:16:44 +0000 |
---|---|---|
committer | petko <petko@524c5546-5005-0410-9a3e-e25e191bd360> | 2024-04-08 08:16:44 +0000 |
commit | e9d6817270fbd86e89c3743d2000d5906bdc222d (patch) | |
tree | ab87eca601fbd0732eab5106203c857902e8d8c0 | |
parent | 1da5b352ac11dfa301c93d7858de1bd71ca39eb1 (diff) | |
download | pmwiki.svn-e9d6817270fbd86e89c3743d2000d5906bdc222d.tar.bz2 |
Fix some cases with conditional markup and markup expressions where an empty code could be evaluated (suggested by Goodguy00).
git-svn-id: svn://pmwiki.org/pmwiki/trunk@4685 524c5546-5005-0410-9a3e-e25e191bd360
-rw-r--r-- | pmwiki.php | 5 | ||||
-rw-r--r-- | scripts/markupexpr.php | 6 |
2 files changed, 7 insertions, 4 deletions
@@ -295,9 +295,10 @@ function CondExpr($pagename, $condname, $condparm) { } ## PITS:01480, (:if [ {$EmptyPV} and ... ]:) - $code = preg_replace('/(^\\s*|(and|x?or|&&|\\|\\||!)\\s+)(?=and|x?or|&&|\\|\\|)/', - '$1 0 ', trim(implode(' ', $terms))); + $code = trim(preg_replace('/(^\\s*|(and|x?or|&&|\\|\\||!)\\s+)(?=and|x?or|&&|\\|\\|)/', + '$1 0 ', trim(implode(' ', $terms)))); + if(!$code) return false; return @eval("return( $code );"); } $Conditions['expr'] = 'CondExpr($pagename, $condname, $condparm)'; diff --git a/scripts/markupexpr.php b/scripts/markupexpr.php index 69d456be..7f7de79b 100644 --- a/scripts/markupexpr.php +++ b/scripts/markupexpr.php @@ -1,5 +1,5 @@ <?php if (!defined('PmWiki')) exit(); -/* Copyright 2007-2021 Patrick R. Michaud (pmichaud@pobox.com) +/* Copyright 2007-2024 Patrick R. Michaud (pmichaud@pobox.com) This file is part of PmWiki; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -108,7 +108,9 @@ function MarkupExpression($pagename, $expr) { ## fix any quoted arguments foreach ($argp as $k => $v) if (!is_array($v)) $argp[$k] = preg_replace_callback($rpat, 'cb_expandkpv', $v); - $out = eval("return ({$code});"); + $code = trim(strval($code)); + if($code === '') $out = ''; + else $out = eval("return ({$code});"); if ($expr == $repl) { $expr = $out; break; } $expr = str_replace($repl, Keep($out, 'P'), $expr); } |