From dbcfe58ea84059ebdd976eaae4a3f61230b12da3 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 24 Jul 2014 22:50:56 +0200 Subject: [PATCH 1/4] parse_url: Removing of warnings with invalid charsets --- mod/parse_url.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mod/parse_url.php b/mod/parse_url.php index 7ab71a2fc5..7f10dce349 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -100,7 +100,7 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co // Fetch the first mentioned charset. Can be in body or header $charset = ""; if (preg_match('/charset=(.*?)['."'".'"\s\n]/', $header, $matches)) - $charset = trim(array_pop($matches)); + $charset = trim(trim(trim(array_pop($matches)), ';,')); if ($charset == "") $charset = "utf-8"; @@ -112,7 +112,12 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co else $body = $header; - $body = mb_convert_encoding($body, "UTF-8", $charset); + if (($charset != '') AND (strtoupper($charset) != "UTF-8")) { + logger("parseurl_getsiteinfo: detected charset ".$charset, LOGGER_DEBUG); + //$body = mb_convert_encoding($body, "UTF-8", $charset); + $body = iconv($charset, "UTF-8//TRANSLIT", $body); + } + $body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8"); $doc = new DOMDocument(); From 46c7cb5b721f4867b06914551a200b47c99cde41 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 24 Jul 2014 22:51:28 +0200 Subject: [PATCH 2/4] bbcode: New mode for conversion of shared content that will be used for g+ and facebook export. --- include/bbcode.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index 84969dab9f..2f4b3df77e 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -452,7 +452,7 @@ function bb_ShareAttributes($share, $simplehtml) { case 2: $text = $preshare.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' '.$userid_compact.":
".$share[3]; break; - case 3: + case 3: // Diaspora $headline = '
'; $headline .= ''.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').$userid.':'; $headline .= "
"; @@ -484,15 +484,21 @@ function bb_ShareAttributes($share, $simplehtml) { case 5: $text = $preshare.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' '.$userid_compact.":
".$share[3]; break; - case 6: + case 6: // app.net $text = $preshare.">> @".$userid_compact.":
".$share[3]; break; - case 7: + case 7: // statusnet/GNU Social $text = $preshare.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')." @".$userid_compact.": ".$share[3]; break; - case 8: + case 8: // twitter $text = $preshare."RT @".$userid_compact.": ".$share[3]; break; + case 9: // Google+/Facebook + $text = $preshare.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' '.$userid_compact.":
".$share[3]; + + if ($link != "") + $text .= "

".$link; + break; default: $headline = trim($share[1]).'
'; if ($avatar != "") @@ -775,7 +781,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $Text = preg_replace("/#\[url\=[$URLSearchString]*\]\^\[\/url\]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/i", "[bookmark=$1]$2[/bookmark]", $Text); - if (in_array($simplehtml, array(2, 6, 7, 8))) { + if (in_array($simplehtml, array(2, 6, 7, 8, 9))) { $Text = preg_replace_callback("/([^#@])\[url\=([^\]]*)\](.*?)\[\/url\]/ism","bb_expand_links",$Text); //$Text = preg_replace("/[^#@]\[url\=([^\]]*)\](.*?)\[\/url\]/ism",' $2 [url]$1[/url]',$Text); $Text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",' $2 [url]$1[/url]',$Text); From e2f9ae397083710cd94b97296a925ebae7e28961 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 24 Jul 2014 22:53:09 +0200 Subject: [PATCH 3/4] Removing of some warnings --- include/text.php | 19 ++++++++++--------- index.php | 6 +++--- .../inc/exceptions/QueryException.class.php | 16 +++++++++------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/include/text.php b/include/text.php index 3c08fe3785..26de709e3e 100644 --- a/include/text.php +++ b/include/text.php @@ -655,7 +655,7 @@ function attribute_contains($attr,$s) { if(! function_exists('logger')) { /* setup int->string log level map */ $LOGGER_LEVELS = array(); - + /** * log levels: * LOGGER_NORMAL (default) @@ -663,7 +663,7 @@ $LOGGER_LEVELS = array(); * LOGGER_DEBUG * LOGGER_DATA * LOGGER_ALL - * + * * @global App $a * @global dba $db * @param string $msg @@ -674,15 +674,16 @@ function logger($msg,$level = 0) { global $a; global $db; global $LOGGER_LEVELS; - + if(($a->module == 'install') || (! ($db && $db->connected))) return; - if (count($LOGGER_LEVEL)==0){ - foreach (get_defined_constants() as $k=>$v){ - if (substr($k,0,7)=="LOGGER_") $LOGGER_LEVELS[$v] = substr($k,7,7); - } - } - + if (count($LOGGER_LEVELS)==0){ + foreach (get_defined_constants() as $k=>$v){ + if (substr($k,0,7)=="LOGGER_") + $LOGGER_LEVELS[$v] = substr($k,7,7); + } + } + $debugging = get_config('system','debugging'); $loglevel = intval(get_config('system','loglevel')); $logfile = get_config('system','logfile'); diff --git a/index.php b/index.php index 335547d74b..1b60071534 100644 --- a/index.php +++ b/index.php @@ -432,7 +432,7 @@ else $a->page['htmlhead'] = str_replace('{{$stylesheet}}',$stylesheet,$a->page['htmlhead']); //$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array('$stylesheet' => $stylesheet)); -if (($_GET["mode"] == "raw") OR ($_GET["mode"] == "minimal")) { +if (isset($_GET["mode"]) AND (($_GET["mode"] == "raw") OR ($_GET["mode"] == "minimal"))) { $doc = new DOMDocument(); $target = new DOMDocument(); @@ -455,7 +455,7 @@ if (($_GET["mode"] == "raw") OR ($_GET["mode"] == "minimal")) { } } -if ($_GET["mode"] == "raw") { +if (isset($_GET["mode"]) AND ($_GET["mode"] == "raw")) { header("Content-type: text/html; charset=utf-8"); @@ -528,7 +528,7 @@ $profile = $a->profile; header("Content-type: text/html; charset=utf-8"); -if ($_GET["mode"] == "minimal") { +if (isset($_GET["mode"]) AND ($_GET["mode"] == "minimal")) { //$page['content'] = substr($target->saveHTML(), 6, -8)."\n\n". // '
'."\n\n"; diff --git a/library/dddbl2/inc/exceptions/QueryException.class.php b/library/dddbl2/inc/exceptions/QueryException.class.php index 52c6250476..e282a18c9a 100644 --- a/library/dddbl2/inc/exceptions/QueryException.class.php +++ b/library/dddbl2/inc/exceptions/QueryException.class.php @@ -19,7 +19,7 @@ class QueryException extends \Exception { * and print them as exception * **/ - public function __construct(\PDOStatement $objPDO, $arrQueryDefinition) { + public function __construct(\PDOStatement $objPDO, array $arrQueryDefinition) { $strMessage = self::createErrorMessage($objPDO, $arrQueryDefinition); @@ -38,7 +38,7 @@ class QueryException extends \Exception { * and query definition * **/ - private function createErrorMessage($objPDO, $arrQueryDefinition) { + private function createErrorMessage(\PDOStatement $objPDO, array $arrQueryDefinition) { $strMessage = self::flattenQueryErrorInfo($objPDO); $strMessage .= self::flattenQueryDefiniton($arrQueryDefinition); @@ -57,7 +57,7 @@ class QueryException extends \Exception { * from the driver specific error message * **/ - private function flattenQueryErrorInfo($objPDO) { + private function flattenQueryErrorInfo(\PDOStatement $objPDO) { $arrErrorInfo = $objPDO->errorInfo(); @@ -76,16 +76,18 @@ class QueryException extends \Exception { * * @return (string) a text version of the query definition * - * create an text, which contains all information - * of the query definition + * create an text, which contains all *scalar* information + * of the query definition. if there are non-scalar information + * added, the will be excluded from output * **/ - private function flattenQueryDefiniton($arrQueryDefinition) { + private function flattenQueryDefiniton(array $arrQueryDefinition) { $strMessage = "\nQuery-Definiton:\n"; foreach($arrQueryDefinition AS $strKeyword => $strContent) - $strMessage .= "$strKeyword: $strContent\n"; + if(is_scalar($strContent)) + $strMessage .= "$strKeyword: $strContent\n"; return $strMessage . "\n"; From 10090a6070feb8d44adc8984ad1a2de7cf12fe6e Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 24 Jul 2014 23:24:10 +0200 Subject: [PATCH 4/4] Removing of warnings to make dav work --- include/dba_pdo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/dba_pdo.php b/include/dba_pdo.php index eed9ea1251..7b720fb6c1 100644 --- a/include/dba_pdo.php +++ b/include/dba_pdo.php @@ -182,13 +182,13 @@ class dba { * These usually indicate SQL syntax errors that need to be resolved. */ - if($result === false) { + if(isset($result) AND ($result === false)) { logger('dba: ' . printable($sql) . ' returned false.' . "\n" . $this->error); if(file_exists('dbfail.out')) file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . ' returned false' . "\n" . $this->error . "\n", FILE_APPEND); } - if(($result === true) || ($result === false)) + if(isset($result) AND (($result === true) || ($result === false))) return $result; if ($onlyquery) {