summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-08-12 21:56:34 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-08-12 21:56:34 +0200
commit7900c5e550acafaf0b877635840a8a270eb06078 (patch)
tree9702d865c7ffb105bc0b0619f6ef99f82e3c8c61
parentede94098be5d330d4bf120eb8064c5c87eed7ef0 (diff)
Move htmlspecialchars_utf8 from Request to Helper
And remove html_chars_utf8 to use htmlspecialchars_utf8 instead in importExportController
-rw-r--r--app/Controllers/importExportController.php10
-rw-r--r--lib/Minz/Helper.php11
-rw-r--r--lib/Minz/Request.php8
-rw-r--r--lib/lib_rss.php4
4 files changed, 17 insertions, 16 deletions
diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php
index 92b39b575..a8e2c2bc2 100644
--- a/app/Controllers/importExportController.php
+++ b/app/Controllers/importExportController.php
@@ -166,15 +166,15 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
}
// We get different useful information
- $url = html_chars_utf8($feed_elt['xmlUrl']);
- $name = html_chars_utf8($feed_elt['text']);
+ $url = Minz_Helper::htmlspecialchars_utf8($feed_elt['xmlUrl']);
+ $name = Minz_Helper::htmlspecialchars_utf8($feed_elt['text']);
$website = '';
if (isset($feed_elt['htmlUrl'])) {
- $website = html_chars_utf8($feed_elt['htmlUrl']);
+ $website = Minz_Helper::htmlspecialchars_utf8($feed_elt['htmlUrl']);
}
$description = '';
if (isset($feed_elt['description'])) {
- $description = html_chars_utf8($feed_elt['description']);
+ $description = Minz_Helper::htmlspecialchars_utf8($feed_elt['description']);
}
$error = false;
@@ -200,7 +200,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
private function addCategoryOpml($cat_elt, $parent_cat) {
// Create a new Category object
- $cat = new FreshRSS_Category(html_chars_utf8($cat_elt['text']));
+ $cat = new FreshRSS_Category(Minz_Helper::htmlspecialchars_utf8($cat_elt['text']));
$id = $this->catDAO->addCategoryObject($cat);
$error = ($id === false);
diff --git a/lib/Minz/Helper.php b/lib/Minz/Helper.php
index b058211d3..13bfdd93e 100644
--- a/lib/Minz/Helper.php
+++ b/lib/Minz/Helper.php
@@ -19,4 +19,15 @@ class Minz_Helper {
return stripslashes($var);
}
}
+
+ /**
+ * Wrapper for htmlspecialchars.
+ * Force UTf-8 value and can be used on array too.
+ */
+ public static function htmlspecialchars_utf8($p) {
+ if (is_array($p)) {
+ return array_map('self::htmlspecialchars_utf8', $p);
+ }
+ return htmlspecialchars($p, ENT_COMPAT, 'UTF-8');
+ }
}
diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php
index f3ecaf55c..52f53012f 100644
--- a/lib/Minz/Request.php
+++ b/lib/Minz/Request.php
@@ -27,19 +27,13 @@ class Minz_Request {
public static function params() {
return self::$params;
}
- static function htmlspecialchars_utf8($p) {
- if (is_array($p)) {
- return array_map('self::htmlspecialchars_utf8', $p);
- }
- return htmlspecialchars($p, ENT_COMPAT, 'UTF-8');
- }
public static function param($key, $default = false, $specialchars = false) {
if (isset(self::$params[$key])) {
$p = self::$params[$key];
if (is_object($p) || $specialchars) {
return $p;
} else {
- return self::htmlspecialchars_utf8($p);
+ return Minz_Helper::htmlspecialchars_utf8($p);
}
} else {
return $default;
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 86c0a4ae4..823f53716 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -230,7 +230,3 @@ function cryptAvailable() {
}
return false;
}
-
-function html_chars_utf8($str) {
- return htmlspecialchars($str, ENT_COMPAT, 'UTF-8');
-}