Overview
Comment: | Add a few default modifiers, and make escape just an alias to htmlspecialchars |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | 7.3 |
Files: | files | file ages | folders |
SHA1: |
239dbded1d4c92aa443abd1e94cb0c48 |
User & Date: | bohwaz on 2021-01-13 01:59:32 |
Other Links: | branch diff | manifest | tags |
Context
2021-01-13
| ||
23:50 | Rename Dumbyer to Brindille check-in: 84ad2e111d user: bohwaz tags: 7.3 | |
01:59 | Add a few default modifiers, and make escape just an alias to htmlspecialchars check-in: 239dbded1d user: bohwaz tags: 7.3 | |
01:23 | Dumbyer: works better now check-in: e727ae7b02 user: bohwaz tags: 7.3 | |
Changes
Modified src/lib/KD2/Dumbyer.php from [94d4a435fe] to [e5552a9bff].
︙ | ︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 47 48 | protected $_stack = []; protected $_sections = []; protected $_modifiers = []; protected $_functions = []; protected $_variables = [0 => []]; public function assign(string $key, $value): void { if (!count($this->_variables)) { $this->_variables = [0 => []]; } | > > > > > > > > > > > > > > > > > > > > > > > | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | protected $_stack = []; protected $_sections = []; protected $_modifiers = []; protected $_functions = []; protected $_variables = [0 => []]; public function registerDefaults() { $this->registerModifier('escape', 'htmlspecialchars'); $this->registerModifier('args', 'sprintf'); $this->registerModifier('nl2br', 'nl2br'); $this->registerModifier('strip_tags', 'strip_tags'); $this->registerModifier('count', 'count'); $this->registerModifier('concatenate', function() { return implode('', func_get_args()); }); $this->registerModifier('date_format', function ($date, $format = '%d/%m/%Y %H:%M') { $tz = null; if (is_object($date)) { $date = $date->getTimestamp(); $tz = $date->getTimezone(); } elseif (!ctype_digit($date)) { $date = strtotime($date); } return Translate::strftime($format, $date, $tz); }); } public function assign(string $key, $value): void { if (!count($this->_variables)) { $this->_variables = [0 => []]; } |
︙ | ︙ | |||
424 425 426 427 428 429 430 | $var = $pre . $var . $post; unset($pre, $post, $arguments, $mod_name, $modifier, $modifiers, $pos, $_post); // auto escape if ($escape) { | | | 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | $var = $pre . $var . $post; unset($pre, $post, $arguments, $mod_name, $modifier, $modifiers, $pos, $_post); // auto escape if ($escape) { $var = '$this->_modifiers[\'escape\'](' . $var . ')'; } return $var; } /** * Parse block arguments, this is similar to parsing HTML arguments |
︙ | ︙ | |||
541 542 543 544 545 546 547 | if (ctype_digit($arg)) { return (int)$arg; } return $arg; } } | < < < < < < < < | 564 565 566 567 568 569 570 571 572 573 574 575 576 | if (ctype_digit($arg)) { return (int)$arg; } return $arg; } } } class Dumbyer_Exception extends \RuntimeException { } |