Permalink
Browse files

Merge branch 'release/1.2.1'

  • Loading branch information...
2 parents 721046e + aebdd75 commit e25b69efac420387007b9b3540b60bb788c58e0a Stephen Lewis committed Sep 12, 2011
Showing with 40 additions and 4 deletions.
  1. +40 −4 ee2/third_party/smartdown/pi.smartdown.php
@@ -7,7 +7,7 @@
* @copyright Experience Internet
* @link http://experienceinternet.co.uk/software/smartdown/
* @package Smartdown
- * @version 1.2.0
+ * @version 1.2.1
*/
require_once PATH_THIRD .'smartdown/markdown/markdown.php';
@@ -20,7 +20,7 @@
'pi_description' => 'Smarter Markdown, with PHP Markdown Extra and SmartyPants for spicy content goodness.',
'pi_name' => 'SmartDown',
'pi_usage' => Smartdown::usage(),
- 'pi_version' => '1.2.0'
+ 'pi_version' => '1.2.1'
);
@@ -61,7 +61,8 @@ public function __construct($tagdata = '')
$functions = $ee->functions;
$tmpl = $ee->TMPL;
- $this->return_data = '';
+ $default_quotes = 2;
+ $this->return_data = '';
/**
* Establish the default settings, and override them with
@@ -72,7 +73,7 @@ public function __construct($tagdata = '')
'disable:markdown' => $config->item('disable:markdown', 'smartdown') === TRUE ? TRUE : FALSE,
'disable:smartypants' => $config->item('disable:smartypants', 'smartdown') === TRUE ? TRUE : FALSE,
'ee_tags:encode' => $config->item('ee_tags:encode', 'smartdown') === TRUE ? TRUE : FALSE,
- 'smart_quotes' => $config->item('smart_quotes', 'smartdown') ? $config->item('smart_quotes', 'smartdown') : '2'
+ 'smart_quotes' => $config->item('smart_quotes', 'smartdown') ? $config->item('smart_quotes', 'smartdown') : $default_quotes
);
if ( ! $tagdata)
@@ -104,6 +105,11 @@ public function __construct($tagdata = '')
);
}
+ // smart_quotes must be a non-negative integer.
+ $settings['smart_quotes'] = $this->_valid_int($settings['smart_quotes'], 0)
+ ? (int) $settings['smart_quotes']
+ : $default_quotes;
+
// Encode EE tags.
if ($settings['ee_tags:encode'])
{
@@ -245,6 +251,36 @@ private function _fix_encoded_ee_code_samples($matches)
}
+ /**
+ * Determines whether the supplied argument is, or can be evaluated to,
+ * a valid integer.
+ *
+ * @param mixed $value The value to check.
+ * @param mixed $min The minimum permissible value.
+ * @param mixed $max The maximum permissible value.
+ * @return bool
+ */
+ private function _valid_int($value, $min = NULL, $max = NULL)
+ {
+ $valid = (is_int($value) OR (is_numeric($value) && intval($value) == $value));
+
+ // If no bounds have been set, we're done.
+ if ( ! $valid OR (is_null($min) && is_null($max)))
+ {
+ return $valid;
+ }
+
+ $min = is_null($min) ? -INF : ($this->_valid_int($min) ? intval($min) : -INF);
+ $max = is_null($max) ? INF : ($this->_valid_int($max) ? intval($max) : INF);
+
+ $value = intval($value);
+ $real_min = min($min, $max);
+ $real_max = max($min, $max);
+
+ return $valid && (min(max($value, $real_min), $real_max) === $value);
+ }
+
+
}

0 comments on commit e25b69e

Please sign in to comment.