diff options
| author | 2013-09-14 17:51:33 +0200 | |
|---|---|---|
| committer | 2013-09-14 17:51:33 +0200 | |
| commit | c63b52738c85ed76c795e62f3238f6cc32cc0b55 (patch) | |
| tree | 6e8fa81e9b5a6f174041c944801c61a9a5563d30 | |
| parent | adc33811c3c9513ca56dfa5e57169a5a1df106db (diff) | |
| parent | da2e4e09d939f49a69cfcd0b3a450f0484f51ff9 (diff) | |
Merge branch 'utf8bug' of https://github.com/Alkarex/FreshRSS into Alkarex-utf8bug
| -rw-r--r-- | app/models/Feed.php | 2 | ||||
| -rwxr-xr-x | app/views/helpers/view/rss_view.phtml | 2 | ||||
| -rw-r--r-- | lib/SimplePie/SimplePie/Misc.php | 2 | ||||
| -rw-r--r-- | lib/lib_phpQuery.php | 2 | ||||
| -rw-r--r-- | lib/lib_rss.php | 2 | ||||
| -rw-r--r-- | lib/minz/Request.php | 4 | ||||
| -rwxr-xr-x | lib/minz/dao/Model_pdo.php | 12 | ||||
| -rw-r--r-- | public/install.php | 7 |
8 files changed, 22 insertions, 11 deletions
diff --git a/app/models/Feed.php b/app/models/Feed.php index 678809af6..0ea083d5a 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -216,7 +216,7 @@ class Feed extends Model { foreach ($feed->get_items () as $item) { $title = $item->get_title (); $title = preg_replace('#<a(.+)>(.+)</a>#', '\\2', $title); - $title = htmlentities($title); + $title = htmlentities($title, ENT_NOQUOTES, 'UTF-8'); $author = $item->get_author (); $link = $item->get_permalink (); $date = strtotime ($item->get_date ()); diff --git a/app/views/helpers/view/rss_view.phtml b/app/views/helpers/view/rss_view.phtml index 83de6de2e..8ce636918 100755 --- a/app/views/helpers/view/rss_view.phtml +++ b/app/views/helpers/view/rss_view.phtml @@ -12,7 +12,7 @@ $items = $this->entryPaginator->items (); foreach ($items as $item) { ?> <item> - <title><?php echo htmlspecialchars(html_entity_decode($item->title ())); ?></title> + <title><?php echo htmlspecialchars(html_entity_decode($item->title (), ENT_NOQUOTES, 'UTF-8'), ENT_NOQUOTES, 'UTF-8'); ?></title> <link><?php echo $item->link (); ?></link> <?php $author = $item->author (); ?> <?php if ($author != '') { ?> diff --git a/lib/SimplePie/SimplePie/Misc.php b/lib/SimplePie/SimplePie/Misc.php index 5d7367f64..621f2c062 100644 --- a/lib/SimplePie/SimplePie/Misc.php +++ b/lib/SimplePie/SimplePie/Misc.php @@ -138,7 +138,7 @@ class SimplePie_Misc foreach ($element['attribs'] as $key => $value) { $key = strtolower($key); - $full .= " $key=\"" . htmlspecialchars($value['data']) . '"'; + $full .= " $key=\"" . htmlspecialchars($value['data'], ENT_COMPAT, 'UTF-8') . '"'; } if ($element['self_closing']) { diff --git a/lib/lib_phpQuery.php b/lib/lib_phpQuery.php index 33ed8a011..4aefb70fe 100644 --- a/lib/lib_phpQuery.php +++ b/lib/lib_phpQuery.php @@ -3365,7 +3365,7 @@ class phpQueryObject */ public function text($text = null, $callback1 = null, $callback2 = null, $callback3 = null) { if (isset($text)) - return $this->html(htmlspecialchars($text)); + return $this->html(htmlspecialchars($text), ENT_NOQUOTES, 'UTF-8'); $args = func_get_args(); $args = array_slice($args, 1); $return = ''; diff --git a/lib/lib_rss.php b/lib/lib_rss.php index a7a5244f8..60e6d3358 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -48,7 +48,7 @@ function opml_export ($cats) { $txt .= '<outline text="' . $cat['name'] . '">' . "\n"; foreach ($cat['feeds'] as $feed) { - $txt .= "\t" . '<outline text="' . cleanText ($feed->name ()) . '" type="rss" xmlUrl="' . htmlentities ($feed->url ()) . '" htmlUrl="' . htmlentities ($feed->website ()) . '" />' . "\n"; + $txt .= "\t" . '<outline text="' . cleanText ($feed->name ()) . '" type="rss" xmlUrl="' . htmlentities ($feed->url (), ENT_COMPAT, 'UTF-8') . '" htmlUrl="' . htmlentities ($feed->website (), ENT_COMPAT, 'UTF-8') . '" />' . "\n"; } $txt .= '</outline>' . "\n"; diff --git a/lib/minz/Request.php b/lib/minz/Request.php index bd5fcb95e..bde17f988 100644 --- a/lib/minz/Request.php +++ b/lib/minz/Request.php @@ -35,9 +35,9 @@ class Request { if(is_object($p) || $specialchars) { return $p; } elseif(is_array($p)) { - return array_map('htmlspecialchars', $p); + return array_map('htmlspecialchars', $p); //TODO: Should use explicit UTF-8 } else { - return htmlspecialchars($p); + return htmlspecialchars($p, ENT_NOQUOTES, 'UTF-8'); } } else { return $default; diff --git a/lib/minz/dao/Model_pdo.php b/lib/minz/dao/Model_pdo.php index a101887d1..6efe5b30f 100755 --- a/lib/minz/dao/Model_pdo.php +++ b/lib/minz/dao/Model_pdo.php @@ -22,23 +22,29 @@ class Model_pdo { */ public function __construct () { $db = Configuration::dataBase (); + $driver_options = null; try { $type = $db['type']; if($type == 'mysql') { $string = $type . ':host=' . $db['host'] - . ';dbname=' . $db['base']; + . ';dbname=' . $db['base'] + . ';charset=utf8'; + $driver_options = array( + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8' + ); } elseif($type == 'sqlite') { $string = $type . ':/' . PUBLIC_PATH - . '/data/' . $db['base'] . '.sqlite'; + . '/data/' . $db['base'] . '.sqlite'; //TODO: DEBUG UTF-8 http://www.siteduzero.com/forum/sujet/sqlite-connexion-utf-8-18797 } $this->bd = new PDO ( $string, $db['user'], - $db['password'] + $db['password'], + $driver_options ); $this->prefix = $db['prefix']; diff --git a/public/install.php b/public/install.php index 3e2d7b0f9..65daed111 100644 --- a/public/install.php +++ b/public/install.php @@ -309,8 +309,12 @@ function checkBD () { try { $str = ''; + $driver_options = null; if($_SESSION['bd_type'] == 'mysql') { $str = 'mysql:host=' . $_SESSION['bd_host'] . ';dbname=' . $_SESSION['bd_name']; + $driver_options = array( + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8' + ); } elseif($_SESSION['bd_type'] == 'sqlite') { $str = 'sqlite:' . PUBLIC_PATH . '/data/' . $_SESSION['bd_name'] . '.sqlite'; @@ -318,7 +322,8 @@ function checkBD () { $c = new PDO ($str, $_SESSION['bd_user'], - $_SESSION['bd_pass']); + $_SESSION['bd_pass'], + $driver_options); $sql = sprintf (SQL_REQ_CAT, $_SESSION['bd_prefix']); $res = $c->query ($sql); |
