aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpetko <petko@524c5546-5005-0410-9a3e-e25e191bd360>2024-04-08 08:16:44 +0000
committerpetko <petko@524c5546-5005-0410-9a3e-e25e191bd360>2024-04-08 08:16:44 +0000
commite9d6817270fbd86e89c3743d2000d5906bdc222d (patch)
treeab87eca601fbd0732eab5106203c857902e8d8c0
parent1da5b352ac11dfa301c93d7858de1bd71ca39eb1 (diff)
downloadpmwiki.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.php5
-rw-r--r--scripts/markupexpr.php6
2 files changed, 7 insertions, 4 deletions
diff --git a/pmwiki.php b/pmwiki.php
index 6afa5c7c..a72db3fa 100644
--- a/pmwiki.php
+++ b/pmwiki.php
@@ -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);
}