4images Forum & Community

4images Help / Hilfe => Bug Fixes & Patches => Topic started by: bildergallery on August 04, 2007, 01:37:28 PM

Title: 1.7.2 - 1.7.4 [FIX] mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: bildergallery on August 04, 2007, 01:37:28 PM
nach mehreren offenen treads habe ich selber versucht, in einer frischen 4images installation
kommentare mit umlauten zu erstellen.

----------------------------------------------------------------------------------------------------------------------

ich benutze als testversion / testsystem
PHP Version 5.2.2 und Mysql 5.0.41

4images 1.7.4

Quelltext im Browser:
<title>4images - Image Gallery Management System</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="./templates/default/style.css" />


----------------------------------------------------------------------------------------------------------------------

folgende fehlermeldung kommt (siehe bild vorher.gif):
Das Feld Überschrift muss ausgefüllt werden!
Das Feld Kommentar muss ausgefüllt werden!

wenn die umlaute durch ae ue oe ersetzt werden, funktioniert dies (siehe bilder nachher.gif)

liebe programmierer, meldet euch  :wink:
damit die sache entgültig gelöst wird :!:


UPDATE 28.08.2007
LÖSUNG/BUGFIX


suche/search in global.php
Code: [Select]
function clean_array($array) {
  $search = array(
    // Remove any attribute starting with "on" or xmlns
    '#(<[^>]+[\x00-\x20\"\'])(on|xmlns)[^>]*>#iUu',
    // Remove javascript: and vbscript: protocol
    '#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu',
    '#([a-z]*)[\x00-\x20]*=([\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu',
    //<span style="width: expression(alert('Ping!'));"></span>
    // Only works in ie...
    '#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*expression[\x00-\x20]*\([^>]*>#iU',
    '#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*behaviour[\x00-\x20]*\([^>]*>#iU',
    '#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iUu'
  );

  $replace = array(
    "$1>",
    '$1=$2nojavascript...',
    '$1=$2novbscript...',
    "$1>",
    "$1>",
    "$1>"
  );

  // Remove all control (i.e. with ASCII value lower than 0x20 (space),
  // except of 0x0A (line feed) and 0x09 (tabulator)
  $search2 =
      "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
  $replace2 = //str_repeat("\r", strlen($search2));
      "\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D";

  foreach ($array as $key => $val) {
    if (is_array($val)) {
      $val = clean_array($val);
    } else {
      $val = preg_replace($search, $replace, $val);

      $val = str_replace("\r\n", "\n", $val);
      $val = str_replace("\r",   "\n", $val);
      $val = strtr($val, $search2, $replace2);
      $val = str_replace("\r", '', $val);  // \r === \x0D

      do {
        $oldval = $val;
        $val = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $val);
      } while ($oldval != $val);
    }

    $array[$key] = $val;
  }

  return $array;
}

ersetze/replace
Code: [Select]
function clean_string($string) {
  $canCheckUTF8Error = defined('PREG_BAD_UTF8_ERROR') && function_exists('preg_last_error');

  // Remove any attribute starting with "on" or xmlns
  $tmp = preg_replace('#(<[^>]+[\x00-\x20\"\'])(on|xmlns)[^>]*>#iUu',"$1>",$string);
  if ($canCheckUTF8Error && (PREG_BAD_UTF8_ERROR == preg_last_error())) {
      $tmp = preg_replace('#(<[^>]+[\x00-\x20\"\'])(on|xmlns)[^>]*>#iU',"$1>",$string);
  }
  $string = $tmp;

  // Remove javascript: and vbscript: protocol
  $tmp = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu','$1=$2nojavascript...',$string);
  if ($canCheckUTF8Error && (PREG_BAD_UTF8_ERROR == preg_last_error())) {
      $tmp = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iU','$1=$2nojavascript...',$string);
  }
  $string = $tmp;
  $tmp = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu','$1=$2novbscript...',$string);
  if ($canCheckUTF8Error && (PREG_BAD_UTF8_ERROR == preg_last_error())) {
      $tmp = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iU','$1=$2novbscript...',$string);
  }
  $string = $tmp;

  // <span style="width: expression(alert('Ping!'));"></span>
  // only works in ie...
  $string = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*expression[\x00-\x20]*\([^>]*>#iU',"$1>",$string);
  $string = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*behaviour[\x00-\x20]*\([^>]*>#iU',"$1>",$string);
  $tmp = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iUu',"$1>",$string);
  if ($canCheckUTF8Error && (PREG_BAD_UTF8_ERROR == preg_last_error())) {
      $tmp = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iU',"$1>",$string);
  }
  $string = $tmp;

  // Remove namespaced elements (we do not need them...)
  $string = preg_replace('#</*\w+:\w[^>]*>#i',"",$string);

  // Remove all control (i.e. with ASCII value lower than 0x20 (space),
  // except of 0x0A (line feed) and 0x09 (tabulator)
  $search =
    "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
  $replace = //str_repeat("\r", strlen($search2));
    "\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D";

  $string = str_replace("\r\n", "\n", $string);
  $string = str_replace("\r",   "\n", $string);
  $string = strtr($string, $search, $replace);
  $string = str_replace("\r", '', $string);  // \r === \x0D

  // Remove really unwanted tags
  do {
    $oldstring = $string;
    $string = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i',"",$string);
  } while ($oldstring != $string);

  return $string;
}

function clean_array($array) {
  foreach ($array as $key => $val) {
    $key = clean_string($key);

    if (is_array($val)) {
      $val = clean_array($val);
    } else {
      $val = clean_string($val);
    }

    $array[$key] = $val;
  }

  return $array;
}
Title: Re: Bug 1.7.4 mit Umlauten in Kommentaren / Comments
Post by: mawenzi on August 04, 2007, 02:27:01 PM
... habe Jan und Kai nochmals auf dieses Problem hingewiesen ...
Title: Re: Bug 1.7.4 mit Umlauten in Kommentaren / Comments
Post by: Jan on August 09, 2007, 01:49:50 PM
Das wurde schon vor ziemlich langer Zeit gefixt (ziemlich am Anfang der global.php).

Jan
Title: Re: Bug 1.7.4 mit Umlauten in Kommentaren / Comments
Post by: Jan on August 14, 2007, 10:19:30 AM
Hi,

wir sind leider hier im Büro seit 1 Woche offline  :|
Ich werde mich sobald es geht darum kümmern..

Jan
Title: Re: Bug 1.7.4 mit Umlauten in Kommentaren / Comments
Post by: Nicky on August 14, 2007, 02:00:14 PM
auf meinem server laufen...

PHP Version 4.3.11
und
MySQL 5.0.22 (datenbank als utf8_general_ci)

an 4images 1.7.4 wurde nichts verändert.

das ist das ergebniss
http://www.nicky.net/4test/details.php?image_id=1
Title: Re: Bug 1.7.4 mit Umlauten in Kommentaren / Comments
Post by: mawenzi on August 14, 2007, 02:34:44 PM
@Nicky
... du bist ja ein Sprachgenie ...  :mrgreen:
... ich denke aber es dreht sich vorrangig um PHP Version 5.x.x ...
Title: Re: Bug 1.7.4 mit Umlauten in Kommentaren / Comments
Post by: Nicky on August 14, 2007, 02:43:51 PM
LOOOOOOOOOL..

ich sollte echt mal die postings komplett lesen.. hab ja nur "5"-er gelesen und dachte auf mysql 5...
damit war mein post überflüssig.

sorry leutz...
Title: Re: Bug 1.7.4 mit Umlauten in Kommentaren / Comments
Post by: Nicky on August 14, 2007, 04:30:07 PM
wieder ich
guckst du... (kann am server zwischen PHP4 und PHP5 wechseln)

PHP Version 5.1.1
MySQL 5.0.22 (datenbank als utf8_general_ci)

http://www.nicky.net/4test/details.php?image_id=1
user: test
pass: test
Title: Re: Bug 1.7.4 mit Umlauten in Kommentaren / Comments
Post by: Jan on August 14, 2007, 06:48:12 PM
Mit register_globals hat das nichts zu tun. 4images war noch nie auf register_globals on angewiesen. Auch die neuen Superglobals können nicht das Problem sein weil wie gesagt schon lange ein Workaround besteht. Ich werde mir das mal in Ruhe anschauen...

Jan
Title: Re: Bug 1.7.4 mit Umlauten in Kommentaren / Comments
Post by: Jan on August 23, 2007, 05:54:45 PM
Hi,

ich hab leider momentan nicht viel Zeit, ich kann den Fehler bei mir nicht nachvollziehen. Hier klappt alles ohne Probleme mit den Umlauten. Hast Du ne URL zu einer Installation bei der es nicht funktioniert?

Gruß Jan
Title: Re: Bug 1.7.4 mit Umlauten in Kommentaren / Comments
Post by: mawenzi on August 23, 2007, 07:01:43 PM
... wenn in dieser Demo-Installation zwar nicht alles so richtig funktioniert, z.b. das captcha image nicht, so funktionieren zumindest die Umlaute in den Kommentaren ...
Title: Re: Bug 1.7.4 mit Umlauten in Kommentaren / Comments
Post by: mawenzi on August 23, 2007, 07:37:11 PM
... Ivan, genauer lesen ...
... die Kommentare funktionieren dort mit Umlauten ... !
... also ist diese Installation ein schlechtes Beispiel für deine Umlaut-Probleme ...
Title: Re: Bug 1.7.4 mit Umlauten in Kommentaren / Comments
Post by: Jan on August 24, 2007, 10:36:11 AM
Ok, der "Fehler" liegt in der Funktion clean_array() in global.php. Ein Workaround ist, folgende Zeile

Code: [Select]
'#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iUu'
in

Code: [Select]
'#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iU'
zu ändern. Also das kleine u am Ende zu entfernen.
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren / Comments
Post by: Jan on August 29, 2007, 05:09:45 PM
global.php

 :flag-de: das ist der Fix /  :flag-en: here the fix:

 :flag-de: Die komplette Funktion /  :flag-en: complete function

Code: [Select]
function clean_array($array) {
  $search = array(
    // Remove any attribute starting with "on" or xmlns
    '#(<[^>]+[\x00-\x20\"\'])(on|xmlns)[^>]*>#iUu',
    // Remove javascript: and vbscript: protocol
    '#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu',
    '#([a-z]*)[\x00-\x20]*=([\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu',
    //<span style="width: expression(alert('Ping!'));"></span>
    // Only works in ie...
    '#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*expression[\x00-\x20]*\([^>]*>#iU',
    '#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*behaviour[\x00-\x20]*\([^>]*>#iU',
    '#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iUu'
  );

  $replace = array(
    "$1>",
    '$1=$2nojavascript...',
    '$1=$2novbscript...',
    "$1>",
    "$1>",
    "$1>"
  );

  // Remove all control (i.e. with ASCII value lower than 0x20 (space),
  // except of 0x0A (line feed) and 0x09 (tabulator)
  $search2 =
      "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
  $replace2 = //str_repeat("\r", strlen($search2));
      "\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D";

  foreach ($array as $key => $val) {
    if (is_array($val)) {
      $val = clean_array($val);
    } else {
      $val = preg_replace($search, $replace, $val);

      $val = str_replace("\r\n", "\n", $val);
      $val = str_replace("\r",   "\n", $val);
      $val = strtr($val, $search2, $replace2);
      $val = str_replace("\r", '', $val);  // \r === \x0D

      do {
        $oldval = $val;
        $val = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $val);
      } while ($oldval != $val);
    }

    $array[$key] = $val;
  }

  return $array;
}

 :flag-de: durch /  :flag-en: replace with

Code: [Select]
function clean_string($string) {
  $canCheckUTF8Error = defined('PREG_BAD_UTF8_ERROR') && function_exists('preg_last_error');

  // Remove any attribute starting with "on" or xmlns
  $tmp = preg_replace('#(<[^>]+[\x00-\x20\"\'])(on|xmlns)[^>]*>#iUu',"$1>",$string);
  if ($canCheckUTF8Error && (PREG_BAD_UTF8_ERROR == preg_last_error())) {
      $tmp = preg_replace('#(<[^>]+[\x00-\x20\"\'])(on|xmlns)[^>]*>#iU',"$1>",$string);
  }
  $string = $tmp;

  // Remove javascript: and vbscript: protocol
  $tmp = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu','$1=$2nojavascript...',$string);
  if ($canCheckUTF8Error && (PREG_BAD_UTF8_ERROR == preg_last_error())) {
      $tmp = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iU','$1=$2nojavascript...',$string);
  }
  $string = $tmp;
  $tmp = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu','$1=$2novbscript...',$string);
  if ($canCheckUTF8Error && (PREG_BAD_UTF8_ERROR == preg_last_error())) {
      $tmp = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iU','$1=$2novbscript...',$string);
  }
  $string = $tmp;

  // <span style="width: expression(alert('Ping!'));"></span>
  // only works in ie...
  $string = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*expression[\x00-\x20]*\([^>]*>#iU',"$1>",$string);
  $string = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*behaviour[\x00-\x20]*\([^>]*>#iU',"$1>",$string);
  $tmp = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iUu',"$1>",$string);
  if ($canCheckUTF8Error && (PREG_BAD_UTF8_ERROR == preg_last_error())) {
      $tmp = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iU',"$1>",$string);
  }
  $string = $tmp;

  // Remove namespaced elements (we do not need them...)
  $string = preg_replace('#</*\w+:\w[^>]*>#i',"",$string);

  // Remove all control (i.e. with ASCII value lower than 0x20 (space),
  // except of 0x0A (line feed) and 0x09 (tabulator)
  $search =
    "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
  $replace = //str_repeat("\r", strlen($search2));
    "\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D";

  $string = str_replace("\r\n", "\n", $string);
  $string = str_replace("\r",   "\n", $string);
  $string = strtr($string, $search, $replace);
  $string = str_replace("\r", '', $string);  // \r === \x0D

  // Remove really unwanted tags
  do {
    $oldstring = $string;
    $string = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i',"",$string);
  } while ($oldstring != $string);

  return $string;
}

function clean_array($array) {
  foreach ($array as $key => $val) {
    $key = clean_string($key);

    if (is_array($val)) {
      $val = clean_array($val);
    } else {
      $val = clean_string($val);
    }

    $array[$key] = $val;
  }

  return $array;
}

 :flag-de: ersetzen.
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren / Comments
Post by: Nicky on August 29, 2007, 09:24:40 PM
dies ist aber schon offtopic ;)

nee, scherz bei seite.. dieser fehler ist bekannt.
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: Jan on August 30, 2007, 09:25:58 AM
Ja, das ist ein Bug.
Fix (in includes/functions.php):

Code: [Select]
"image_name" => $image_name,
ersetzen durch

Code: [Select]
"image_name" => format_text($image_name, 2),
und (kommt 3x vor)

Code: [Select]
alt=\"".$image_name."\"
ersetzen durch

Code: [Select]
alt=\"".format_text($image_name, 2)."\"


Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: mawenzi on August 30, 2007, 11:45:38 AM
@Jan , @Kai oder @Nicky

... die beiden Fixes sollten in den Thread "Bug Fixes & Patches" (http://www.4homepages.de/forum/index.php?board=17.0) aufgenommen werden ...  :!:
... sonst gehen sie für viele User hier unter ...
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: lordi on October 16, 2007, 09:19:45 PM
guys

can someone translate to me ???

i didn't understand anything!!!!!!!

plz

i have 1.7.4 version
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: kai on October 17, 2007, 12:53:41 PM
@ lordi: It's a fix for posting comments with special characters like ü ö ä å ...
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: Alessio on October 20, 2007, 12:32:52 PM
guys

can someone translate to me ???

i didn't understand anything!!!!!!!

plz

i have 1.7.4 version

Use google translation
http://translate.google.com/translate?u=http%3A%2F%2Fwww.4homepages.de%2Fforum%2Findex.php%3Ftopic%3D18256.0&langpair=de%7Cen&hl=it&ie=UTF-8&oe=UTF-8&prev=%2Flanguage_tools
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: thunderstrike on October 20, 2007, 02:43:51 PM
No need for Google translation. Is say in english on right of each step.
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: marcuskillen on January 10, 2008, 02:11:47 PM
thx !!! the fix did it for me  :lol: äöåööåä no problems now
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: Jan-Lukas on January 23, 2008, 12:19:48 AM
hätte hier auch noch etwas zum fixen  :wink: (hoffe bin hier richtig)
Und zwar wird im Bildnamen kein Zeilenumbruchzeichen mehr interpretiert
Wir hatten in der 1.7.1 wegen der Übersichtlichkeit einige <br> eingebaut, hat auch immer geklappt, hier in der 1.7.4 leider nicht
habe die Fixes dieser Seite alle eingebaut.

(http://ue-ei-portal.de/uploads/forum2/c5571cd1a0516354e536ae0cc800b643.jpg)

gruss Harald




Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: mawenzi on January 23, 2008, 01:30:53 AM
Hallo Harald,

... hast natürlich Recht ... gehört eigentlich nicht hierher ... aber trotzdem ...  :wink:
... ungetestet ... aber versuche mal Folgendes in der includes/functions.php ...
... statt ...
Code: [Select]
"image_name" => format_text($image_row['image_name'], 2),
... dieses ...
Code: [Select]
"image_name" => format_text($image_row['image_name'], 1, 0, 1),
... damit sollte die html-Konfiguration für den Bildnamen erfolgen und <br> als Umbruch ausgeführt werden ...


Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: Jan-Lukas on January 23, 2008, 01:52:02 AM
Hallo Detlev,
Du hast wohl auch kein Bett ;)
hatte leider keinen besseren Threat gefunden  :o

So, hab es eingebaut, doch leider kein Erfolg  :cry:

Danke Harald
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: mawenzi on January 23, 2008, 03:18:42 AM
@ Harald,

... habe die Codezeile noch mal geändert ... wiederum ungetestet ...
... ansonsten müsste ich mal mit 'nem Test anfangen ...

Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: Jan-Lukas on January 23, 2008, 09:54:18 AM
Nachteule  :wink:

So, in der Kategorie übersicht klappt es jetzt, nur in der Detailübersicht noch nicht
http://www.ue-ei-portal-sammlerkatalog.de/details.php?image_id=38763

gibt es da 2 verschiedene Stellen zum ändern ?
obwohl hat es mich da immer gestört, weil dann eine 2te Zeile angefangen wurde :?
Kann man da nicht ausklammern ? so das es da nicht angezeigt wird 

Harald
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: nikitaspj on January 23, 2008, 07:00:43 PM
Hallo guys ;)
i am a new user of 4images
I faced the problem with special characters (i am from Greece      αβγδεζ.....  )
the fix seems to work for me now


but i dont understand if i have to do and that (i copy paste from the Jan's Reply #29 on: August 30, 2007, 09:25:58 AM )

Fix (in includes/functions.php):

Code:
"image_name" => $image_name,

ersetzen durch

Code:
"image_name" => format_text($image_name, 2),

und (kommt 3x vor)

Code:
alt=\"".$image_name."\"

ersetzen durch

Code:
alt=\"".format_text($image_name, 2)."\"


and most important it would be right to post the fix with another title
cause the word Umlauten there will be many people that they will not understand.
When i was a kid i tried to learn Deutch and that little knowledge helped me understand that there is a Special Character issue.If i didn't knew ,maybe i would still try to find the solution .
The bug propably affects all the users that their languages have special characters.Slavic Arab Greek Turkish Chinese etc etc.Some they have allready posted about the prob and some of these threads seem unsolved.
so it would be Real Helpfull if u post it as a
Special Characters Bug in Upload -Comments -Search sollution

danke schön
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: mawenzi on January 23, 2008, 08:16:32 PM
@ nikitaspj
... this fix in fuctions.php has nothing to do with the fix for posting comments with special characters ...
... it is a special fix for Jan-Lucas request ...
... and you are right ...
... "it would be Real Helpfull if u post it as a Special Characters Bug in Upload -Comments -Search sollution" ...
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: Thotty on February 17, 2008, 09:28:40 AM
Ich habe Keywords mit Umlauten und nun das Problem, dass diese (auch mit dem Fix) nicht gefunden werden.
Erst wenn ich das Bild übers Control Panel aufrufe und auf Änderungen Speichern klicke, werden Bilder mit Umlaut-Keywords gefunden. :!:

Woran liegt das und gibts irgend 'ne Möglichkeit, das per SQL zu machen, damit ich das nicht bei jedem Bild einzeln machen muss? :?:
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: Jan on February 18, 2008, 10:34:15 AM
Mit diesem Plugin den Suchindex neu erstellen:
http://www.4homepages.de/forum/index.php?topic=6718.0
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: Thotty on February 18, 2008, 12:30:41 PM
Hallo Jan,

vielen Dank für den Tipp! :)
Hat prima funktioniert! :D
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: RoadDogg on April 01, 2008, 07:23:58 PM
Mit diesem Plugin den Suchindex neu erstellen:
http://www.4homepages.de/forum/index.php?topic=6718.0

Fantastisch. Damit funktioniert die Umlautsuche nun auch wieder. :D
Title: Re: [FIX] 1.7.4 mit Umlauten in Kommentaren / Comments
Post by: Markus/TSC on October 13, 2008, 11:41:07 AM
Hallo!

Kurze Frage: Der zitierte Code ist doch bei der global.php in Version 1.7.6 schon drin, wie ich das gesehen habe.. Ich bin mit der Galerie umgezogen und habe gleichzeitig ein Update von 1.7.4 auf 1.7.6 gemacht und bekomme die Umlaute nicht mehr dargestellt. Nur wäre es ja Quatsch wenn ich den u.a. Code nochmal einfüge, da er ja schon vorhanden ist!?

global.php

 :flag-de: das ist der Fix /  :flag-en: here the fix:

 :flag-de: Die komplette Funktion /  :flag-en: complete function

 :flag-de: durch /  :flag-en: replace with

Code: [Select]
function clean_string($string) {
  $canCheckUTF8Error = defined('PREG_BAD_UTF8_ERROR') && function_exists('preg_last_error');

  // Remove any attribute starting with "on" or xmlns
  $tmp = preg_replace('#(<[^>]+[\x00-\x20\"\'])(on|xmlns)[^>]*>#iUu',"$1>",$string);
  if ($canCheckUTF8Error && (PREG_BAD_UTF8_ERROR == preg_last_error())) {
      $tmp = preg_replace('#(<[^>]+[\x00-\x20\"\'])(on|xmlns)[^>]*>#iU',"$1>",$string);
  }
  $string = $tmp;

  // Remove javascript: and vbscript: protocol
  $tmp = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu','$1=$2nojavascript...',$string);
  if ($canCheckUTF8Error && (PREG_BAD_UTF8_ERROR == preg_last_error())) {
      $tmp = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iU','$1=$2nojavascript...',$string);
  }
  $string = $tmp;
  $tmp = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu','$1=$2novbscript...',$string);
  if ($canCheckUTF8Error && (PREG_BAD_UTF8_ERROR == preg_last_error())) {
      $tmp = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iU','$1=$2novbscript...',$string);
  }
  $string = $tmp;

  // <span style="width: expression(alert('Ping!'));"></span>
  // only works in ie...
  $string = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*expression[\x00-\x20]*\([^>]*>#iU',"$1>",$string);
  $string = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*behaviour[\x00-\x20]*\([^>]*>#iU',"$1>",$string);
  $tmp = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iUu',"$1>",$string);
  if ($canCheckUTF8Error && (PREG_BAD_UTF8_ERROR == preg_last_error())) {
      $tmp = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iU',"$1>",$string);
  }
  $string = $tmp;

  // Remove namespaced elements (we do not need them...)
  $string = preg_replace('#</*\w+:\w[^>]*>#i',"",$string);

  // Remove all control (i.e. with ASCII value lower than 0x20 (space),
  // except of 0x0A (line feed) and 0x09 (tabulator)
  $search =
    "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
  $replace = //str_repeat("\r", strlen($search2));
    "\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D\x0D";

  $string = str_replace("\r\n", "\n", $string);
  $string = str_replace("\r",   "\n", $string);
  $string = strtr($string, $search, $replace);
  $string = str_replace("\r", '', $string);  // \r === \x0D

  // Remove really unwanted tags
  do {
    $oldstring = $string;
    $string = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i',"",$string);
  } while ($oldstring != $string);

  return $string;
}

function clean_array($array) {
  foreach ($array as $key => $val) {
    $key = clean_string($key);

    if (is_array($val)) {
      $val = clean_array($val);
    } else {
      $val = clean_string($val);
    }

    $array[$key] = $val;
  }

  return $array;
}

 :flag-de: ersetzen.
Title: Re: 1.7.2 - 1.7.4 [FIX] mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: kai on October 13, 2008, 12:53:28 PM
@ Markus / TSC:
Beim Import der DB hast Du wahrscheinlich eine andere collation gewählt.

http://www.4homepages.de/forum/index.php?topic=16651.0
Title: Re: 1.7.2 - 1.7.4 [FIX] mit Umlauten in Kommentaren-/Suche - Comments-/Search
Post by: shahrahan on December 30, 2018, 07:36:42 AM
als anhang noch die datenbank struktur mit kollation latin1_general_ci