1
0

fix native charset böog missing smarty entry title

Basically not a Smarty error. Just a php htmlspecialchars($entry['title']) setting this var to be empty.

References #236
This commit is contained in:
Ian
2014-11-21 18:03:26 +01:00
parent 35698284d6
commit 8f894f50f1
2 changed files with 44 additions and 43 deletions

View File

@ -1,4 +1,4 @@
<?php # $Id$ <?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team) # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details # All rights reserved. See LICENSE file for licensing details
@ -69,7 +69,7 @@ function serendipity_getMultiCategoriesSQL($cats, $invert = false) {
$cat_sql_array[] = " (c.category_left " . ($invert ? " NOT " : "") . " BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange($categoryid)) . ')'; $cat_sql_array[] = " (c.category_left " . ($invert ? " NOT " : "") . " BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange($categoryid)) . ')';
} }
} }
if (count($cat_sql_array) < 1) { if (count($cat_sql_array) < 1) {
return ''; return '';
} }
@ -381,7 +381,7 @@ function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fe
LEFT JOIN {$serendipity['dbPrefix']}category c LEFT JOIN {$serendipity['dbPrefix']}category c
ON ec.categoryid = c.categoryid"; ON ec.categoryid = c.categoryid";
} }
if ($joinown) { if ($joinown) {
$cond['joins'] .= $joinown; $cond['joins'] .= $joinown;
} }
@ -394,7 +394,7 @@ function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fe
if (isset($serendipity['GET']['page']) && ($serendipity['GET']['page'] > 1 || serendipity_db_bool($serendipity['archiveSortStable'])) && !strstr($limit, ',')) { if (isset($serendipity['GET']['page']) && ($serendipity['GET']['page'] > 1 || serendipity_db_bool($serendipity['archiveSortStable'])) && !strstr($limit, ',')) {
if (serendipity_db_bool($serendipity['archiveSortStable'])) { if (serendipity_db_bool($serendipity['archiveSortStable'])) {
$totalEntries = serendipity_getTotalEntries(); $totalEntries = serendipity_getTotalEntries();
$totalPages = ceil($totalEntries / $limit); $totalPages = ceil($totalEntries / $limit);
if ($totalPages <= 0 ) { if ($totalPages <= 0 ) {
$totalPages = 1; $totalPages = 1;
@ -740,7 +740,7 @@ function serendipity_rebuildCategoryTree($parent = 0, $left = 0) {
function &serendipity_searchEntries($term, $limit = '', $searchresults = '') { function &serendipity_searchEntries($term, $limit = '', $searchresults = '') {
global $serendipity; global $serendipity;
static $log_queries = false; static $log_queries = false;
if ($log_queries) { if ($log_queries) {
$fp = fopen($serendipity['serendipityPath'] . '/archives/queries.csv', 'a'); $fp = fopen($serendipity['serendipityPath'] . '/archives/queries.csv', 'a');
fwrite($fp, date('Y-m-d H:i') . ';' fwrite($fp, date('Y-m-d H:i') . ';'
@ -767,7 +767,7 @@ function &serendipity_searchEntries($term, $limit = '', $searchresults = '') {
$serendipity['dbType'] == 'pdo-postgres') { $serendipity['dbType'] == 'pdo-postgres') {
$cond['group'] = ''; $cond['group'] = '';
$cond['distinct'] = 'DISTINCT'; $cond['distinct'] = 'DISTINCT';
$r = serendipity_db_query("SELECT count(routine_name) AS counter $r = serendipity_db_query("SELECT count(routine_name) AS counter
FROM information_schema.routines FROM information_schema.routines
WHERE routine_name LIKE 'to_tsvector' WHERE routine_name LIKE 'to_tsvector'
@ -778,7 +778,7 @@ function &serendipity_searchEntries($term, $limit = '', $searchresults = '') {
to_tsvector('english', title) @@to_tsquery('$term') OR to_tsvector('english', title) @@to_tsquery('$term') OR
to_tsvector('english', body) @@to_tsquery('$term') OR to_tsvector('english', body) @@to_tsquery('$term') OR
to_tsvector('english', extended) @@to_tsquery('$term') to_tsvector('english', extended) @@to_tsquery('$term')
)"; )";
} else { } else {
$cond['find_part'] = "(title ILIKE '%$term%' OR body ILIKE '%$term%' OR extended ILIKE '%$term%')"; $cond['find_part'] = "(title ILIKE '%$term%' OR body ILIKE '%$term%' OR extended ILIKE '%$term%')";
} }
@ -865,7 +865,7 @@ function &serendipity_searchEntries($term, $limit = '', $searchresults = '') {
foreach($searchresults AS $idx => $data) { foreach($searchresults AS $idx => $data) {
$ids_current[$data['id']] = true; $ids_current[$data['id']] = true;
} }
foreach($search AS $idx => $data) { foreach($search AS $idx => $data) {
if (isset($ids_current[$data['id']])) { if (isset($ids_current[$data['id']])) {
unset($search[$idx]); unset($search[$idx]);
@ -878,7 +878,7 @@ function &serendipity_searchEntries($term, $limit = '', $searchresults = '') {
if ($p == 0) $p = 1; if ($p == 0) $p = 1;
//if * wasn't already appended and if there are none or not enough //if * wasn't already appended and if there are none or not enough
//results, search again for entries containing the searchterm as a part //results, search again for entries containing the searchterm as a part
if ($p == 1 && strpos($term, '*') === false && $serendipity['dbType'] != 'sqlite' && $serendipity['dbType'] != 'sqlite3' && $serendipity['dbType'] != 'pdo-sqlite') { if ($p == 1 && strpos($term, '*') === false && $serendipity['dbType'] != 'sqlite' && $serendipity['dbType'] != 'sqlite3' && $serendipity['dbType'] != 'pdo-sqlite') {
if (! is_array($search)) { if (! is_array($search)) {
return serendipity_searchEntries($term.'*', $orig_limit); return serendipity_searchEntries($term.'*', $orig_limit);
@ -893,11 +893,11 @@ function &serendipity_searchEntries($term, $limit = '', $searchresults = '') {
} }
} }
} }
if (is_array($search)){ if (is_array($search)){
serendipity_fetchEntryData($search); serendipity_fetchEntryData($search);
} }
return $search; return $search;
} }
@ -918,7 +918,7 @@ function serendipity_printEntryFooter($suffix = '.html', $totalEntries = null) {
if ($totalEntries === null) { if ($totalEntries === null) {
$totalEntries = serendipity_getTotalEntries(); $totalEntries = serendipity_getTotalEntries();
} }
$limits = explode(',', $serendipity['fetchLimit']); $limits = explode(',', $serendipity['fetchLimit']);
if (!empty($limits[1])) { if (!empty($limits[1])) {
$limit = (int)$limits[1]; $limit = (int)$limits[1];
@ -1048,7 +1048,7 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm
return; // no display of this item return; // no display of this item
} }
} }
// We shouldn't return here, because we want Smarty to handle the output // We shouldn't return here, because we want Smarty to handle the output
if (!is_array($entries) || $entries[0] == false || !isset($entries[0]['timestamp'])) { if (!is_array($entries) || $entries[0] == false || !isset($entries[0]['timestamp'])) {
$entries = array(); $entries = array();
@ -1139,15 +1139,15 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm
'realname' => $entry['author'] 'realname' => $entry['author']
); );
$entry['link'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp'])); $entry['link'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
$entry['commURL'] = serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', false, array('timestamp' => $entry['timestamp'])); $entry['commURL'] = serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', false, array('timestamp' => $entry['timestamp']));
$entry['html_title']= $entry['title']; $entry['html_title'] = $entry['title'];
$entry['title'] = htmlspecialchars($entry['title']); $entry['title'] = LANG_CHARSET != 'UTF-8' ? $entry['title'] : htmlspecialchars($entry['title']);
$entry['title_rdf'] = preg_replace('@-{2,}@', '-', $entry['html_title']); $entry['title_rdf'] = preg_replace('@-{2,}@', '-', $entry['html_title']);
$entry['rdf_ident'] = serendipity_archiveURL($entry['id'], $entry['title_rdf'], 'baseURL', true, array('timestamp' => $entry['timestamp'])); $entry['rdf_ident'] = serendipity_archiveURL($entry['id'], $entry['title_rdf'], 'baseURL', true, array('timestamp' => $entry['timestamp']));
$entry['link_rdf'] = serendipity_rewriteURL(PATH_FEEDS . '/ei_'. $entry['id'] .'.rdf'); $entry['link_rdf'] = serendipity_rewriteURL(PATH_FEEDS . '/ei_'. $entry['id'] .'.rdf');
$entry['title_rdf'] = htmlspecialchars($entry['title_rdf']); $entry['title_rdf'] = htmlspecialchars($entry['title_rdf']);
$entry['link_allow_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=enable&amp;serendipity[entry]=' . $entry['id']; $entry['link_allow_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=enable&amp;serendipity[entry]=' . $entry['id'];
$entry['link_deny_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=disable&amp;serendipity[entry]=' . $entry['id']; $entry['link_deny_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=disable&amp;serendipity[entry]=' . $entry['id'];
@ -1233,9 +1233,9 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm
} }
if ($smarty_fetch === 'return') { if ($smarty_fetch === 'return') {
return $dategroup; return $dategroup;
} }
$serendipity['smarty']->assignByRef('entries', $dategroup); $serendipity['smarty']->assignByRef('entries', $dategroup);
unset($entries, $dategroup); unset($entries, $dategroup);
@ -1309,7 +1309,7 @@ function serendipity_updertEntry($entry) {
$categories = $entry['categories']; $categories = $entry['categories'];
unset($entry['categories']); unset($entry['categories']);
$had_categories = $entry['had_categories']; $had_categories = $entry['had_categories'];
unset($entry['had_categories']); unset($entry['had_categories']);
@ -1662,7 +1662,7 @@ function serendipity_printArchives() {
WHERE isdraft = 'false'" WHERE isdraft = 'false'"
. (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND timestamp <= " . serendipity_db_time() : '') . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND timestamp <= " . serendipity_db_time() : '')
. (!empty($cat_sql) ? ' AND ' . $cat_sql : '') . (!empty($cat_sql) ? ' AND ' . $cat_sql : '')
. (!empty($serendipity['GET']['viewAuthor']) ? ' AND e.authorid = ' . (int)$serendipity['GET']['viewAuthor'] : '') . (!empty($serendipity['GET']['viewAuthor']) ? ' AND e.authorid = ' . (int)$serendipity['GET']['viewAuthor'] : '')
. (!empty($cat_sql) ? " GROUP BY e.id, e.timestamp" : ''); . (!empty($cat_sql) ? " GROUP BY e.id, e.timestamp" : '');
$entries =& serendipity_db_query($q, false, 'assoc'); $entries =& serendipity_db_query($q, false, 'assoc');

View File

@ -60,8 +60,8 @@ function &serendipity_printTrackbacks(&$trackbacks) {
* @param int The unix timestamp to format * @param int The unix timestamp to format
* @return timestamp in ISO-format * @return timestamp in ISO-format
*/ */
function serendipity_smarty_html5time($timestamp) { function serendipity_smarty_html5time($timestamp) {
return date("c", $timestamp); return date("c", $timestamp);
} }
@ -194,7 +194,7 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) {
if (empty($params['fetchDrafts'])) { if (empty($params['fetchDrafts'])) {
$params['fetchDrafts'] = false; $params['fetchDrafts'] = false;
} }
if (!empty($params['entryprops'])) { if (!empty($params['entryprops'])) {
if (preg_match_all('@(.*)(!)?=[\'"]*([^\'"]+)[\'"]*(,|$)@imsU', $params['entryprops'], $m)) { if (preg_match_all('@(.*)(!)?=[\'"]*([^\'"]+)[\'"]*(,|$)@imsU', $params['entryprops'], $m)) {
foreach($m[0] AS $idx => $p) { foreach($m[0] AS $idx => $p) {
@ -344,7 +344,7 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) {
break; break;
} }
} }
if ($params['returncode'] == 'query') { if ($params['returncode'] == 'query') {
return print_r($entry, true); return print_r($entry, true);
} }
@ -768,7 +768,7 @@ function &serendipity_smarty_printComments($params, &$smarty) {
if (empty($params['depth'])) { if (empty($params['depth'])) {
$params['depth'] = 0; $params['depth'] = 0;
} }
if (empty($params['trace'])) { if (empty($params['trace'])) {
$params['trace'] = null; $params['trace'] = null;
} }
@ -776,11 +776,11 @@ function &serendipity_smarty_printComments($params, &$smarty) {
if (empty($params['block'])) { if (empty($params['block'])) {
$params['block'] = 'COMMENTS'; $params['block'] = 'COMMENTS';
} }
if (empty($params['template'])) { if (empty($params['template'])) {
$params['template'] = 'comments.tpl'; $params['template'] = 'comments.tpl';
} }
$out = serendipity_printComments($comments, $params['mode'], $params['depth'], $params['trace'], $params['block'], $params['template']); $out = serendipity_printComments($comments, $params['mode'], $params['depth'], $params['trace'], $params['block'], $params['template']);
return $out; return $out;
} }
@ -838,7 +838,7 @@ function serendipity_smarty_getImageSize($params, &$smarty) {
if (!isset($params['file'])) { if (!isset($params['file'])) {
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'file' parameter", E_USER_WARNING); trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'file' parameter", E_USER_WARNING);
return; return;
} }
if (!isset($params['assign'])) { if (!isset($params['assign'])) {
trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'assign' parameter", E_USER_WARNING); trigger_error("Smarty Error: " . __FUNCTION__ .": missing 'assign' parameter", E_USER_WARNING);
return; return;
@ -902,8 +902,9 @@ function serendipity_smarty_init($vars = array()) {
// Set a session variable if Smarty fails: // Set a session variable if Smarty fails:
$prev_smarty = $_SESSION['no_smarty']; $prev_smarty = $_SESSION['no_smarty'];
$_SESSION['no_smarty'] = true; $_SESSION['no_smarty'] = true;
if (LANG_CHARSET != 'UTF-8') { if (LANG_CHARSET != 'UTF-8') {
@define('SMARTY_MBSTRING', false);
@define('SMARTY_RESOURCE_CHAR_SET', LANG_CHARSET); @define('SMARTY_RESOURCE_CHAR_SET', LANG_CHARSET);
} }
@ -925,7 +926,7 @@ function serendipity_smarty_init($vars = array()) {
if (!class_exists('Serendipity_Smarty')) { if (!class_exists('Serendipity_Smarty')) {
include_once S9Y_INCLUDE_PATH . '/include/serendipity_smarty_class.inc.php'; include_once S9Y_INCLUDE_PATH . '/include/serendipity_smarty_class.inc.php';
} }
if (!class_exists('Serendipity_Smarty')) { if (!class_exists('Serendipity_Smarty')) {
return false; return false;
} }
@ -940,7 +941,7 @@ function serendipity_smarty_init($vars = array()) {
$_SESSION['no_smarty'] = $prev_smarty; $_SESSION['no_smarty'] = $prev_smarty;
// enable security policy by instance of the Smarty_Security class // enable security policy by instance of the Smarty_Security class
$serendipity['smarty']->enableSecurity('Serendipity_Smarty_Security_Policy'); $serendipity['smarty']->enableSecurity('Serendipity_Smarty_Security_Policy');
// debugging... // debugging...
#echo '<pre>';print_r($serendipity['smarty']);echo '</pre>';#exit; #echo '<pre>';print_r($serendipity['smarty']);echo '</pre>';#exit;
@ -948,7 +949,7 @@ function serendipity_smarty_init($vars = array()) {
// extreme debugging with undocumented internal flag which enables a trace output from the parser during debugging // extreme debugging with undocumented internal flag which enables a trace output from the parser during debugging
#$serendipity['smarty']->_parserdebug = true; // be careful! #$serendipity['smarty']->_parserdebug = true; // be careful!
/** /**
* ToDo: Check for possible API changes in Smarty 3.2 [smarty_modifier_foobar, --> [smarty_modifier_foobar, smarty_function_foobar, smarty_block_foobar] (in class)] * ToDo: Check for possible API changes in Smarty 3.2 [smarty_modifier_foobar, --> [smarty_modifier_foobar, smarty_function_foobar, smarty_block_foobar] (in class)]
* smarty_modifier_foobar(Smarty $smarty, $string, ...) vs. smarty_modifier_foobar($string, ...) * smarty_modifier_foobar(Smarty $smarty, $string, ...) vs. smarty_modifier_foobar($string, ...)
**/ **/
@ -976,9 +977,9 @@ function serendipity_smarty_init($vars = array()) {
$serendipity['smarty']->registerPlugin('function', 'serendipity_getImageSize', 'serendipity_smarty_getImageSize'); $serendipity['smarty']->registerPlugin('function', 'serendipity_getImageSize', 'serendipity_smarty_getImageSize');
$serendipity['smarty']->registerPlugin('function', 'serendipity_getConfigVar', 'serendipity_smarty_getConfigVar'); $serendipity['smarty']->registerPlugin('function', 'serendipity_getConfigVar', 'serendipity_smarty_getConfigVar');
$serendipity['smarty']->registerPlugin('function', 'serendipity_setFormToken', 'serendipity_smarty_setFormToken'); $serendipity['smarty']->registerPlugin('function', 'serendipity_setFormToken', 'serendipity_smarty_setFormToken');
$serendipity['smarty']->registerFilter('pre', 'serendipity_replaceSmartyVars'); $serendipity['smarty']->registerFilter('pre', 'serendipity_replaceSmartyVars');
} }
if (!isset($serendipity['smarty_file'])) { if (!isset($serendipity['smarty_file'])) {
@ -1017,7 +1018,7 @@ function serendipity_smarty_init($vars = array()) {
} else { } else {
$serendipity['smarty_vars']['head_link_script'] = serendipity_rewriteURL('serendipity.js'); $serendipity['smarty_vars']['head_link_script'] = serendipity_rewriteURL('serendipity.js');
} }
if (strstr($serendipity['smarty_vars']['head_link_script'], '?')) { if (strstr($serendipity['smarty_vars']['head_link_script'], '?')) {
$serendipity['smarty_vars']['head_link_script'] .= '&amp;v=' . $serendipity['last_template_change']; $serendipity['smarty_vars']['head_link_script'] .= '&amp;v=' . $serendipity['last_template_change'];
} else { } else {
@ -1191,11 +1192,11 @@ function serendipity_smarty_shutdown($serendipity_directory = '') {
*/ */
function serendipity_smarty_show($template, $data = null) { function serendipity_smarty_show($template, $data = null) {
global $serendipity; global $serendipity;
if (!is_object($serendipity['smarty'])) { if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init(); serendipity_smarty_init();
} }
$serendipity['smarty']->assign($data); $serendipity['smarty']->assign($data);
return $serendipity['smarty']->fetch(serendipity_getTemplateFile($template, 'serendipityPath')); return $serendipity['smarty']->fetch(serendipity_getTemplateFile($template, 'serendipityPath'));