Просмотр исходного кода

* When CharSet is not 'iso-8859-1' or 'iso-8859-15', don't provide
conversions for characters. Fixes problems for many other languages, e.g.
greek, korean etc.

Morten Brix Pedersen 23 лет назад
Родитель
Сommit
0f1d3a0acb
3 измененных файлов с 35 добавлено и 26 удалено
  1. 3 0
      docs/Changelog
  2. 17 14
      modules/Pisg/Common.pm
  3. 15 12
      modules/Pisg/HTMLGenerator.pm

+ 3 - 0
docs/Changelog

@@ -10,6 +10,9 @@ pisg (x.xx)
    * Add modified version of patch from minicus - allows browser to split words
      at QuoteWidth number of characters into any given word, without splitting
      URL's (new config option)
+   * When CharSet is not 'iso-8859-1' or 'iso-8859-15', don't provide
+     conversions for characters. Fixes problems for many other languages, e.g.
+     greek, korean etc.
    * Fix bug in mIRC6 format where it didn't recognize logfiles logging seconds
    * Fix bug in mIRC6 format where it didn't recognize kicks of the maintainer
    * Add support for sirc format (thanks bartko)

+ 17 - 14
modules/Pisg/Common.pm

@@ -184,20 +184,23 @@ sub match_email
 sub htmlentities
 {
     my $str = shift;
-
-    $str =~ s/\&/\&/go;
-    $str =~ s/\</\&lt;/go;
-    $str =~ s/\>/\&gt;/go;
-    $str =~ s/ü/&uuml;/go;
-    $str =~ s/ö/&ouml;/go;
-    $str =~ s/ä/&auml;/go;
-    $str =~ s/ß/&szlig;/go;
-    $str =~ s/å/&aring;/go;
-    $str =~ s/æ/&aelig;/go;
-    $str =~ s/ø/&oslash;/go;
-    $str =~ s/Å/&Aring;/go;
-    $str =~ s/Æ/&AElig;/go;
-    $str =~ s/Ø/&Oslash;/go;
+    my $charset = shift;
+
+    if ($charset eq "iso-8859-1" or $charset eq "iso-8859-15") {
+        $str =~ s/\&/\&amp;/go;
+        $str =~ s/\</\&lt;/go;
+        $str =~ s/\>/\&gt;/go;
+        $str =~ s/ü/&uuml;/go;
+        $str =~ s/ö/&ouml;/go;
+        $str =~ s/ä/&auml;/go;
+        $str =~ s/ß/&szlig;/go;
+        $str =~ s/å/&aring;/go;
+        $str =~ s/æ/&aelig;/go;
+        $str =~ s/ø/&oslash;/go;
+        $str =~ s/Å/&Aring;/go;
+        $str =~ s/Æ/&AElig;/go;
+        $str =~ s/Ø/&Oslash;/go;
+    }
 
     return $str;
 }

+ 15 - 12
modules/Pisg/HTMLGenerator.pm

@@ -1496,16 +1496,19 @@ sub _template_text
 
     foreach my $key (sort keys %hash) {
         $text =~ s/\[:$key\]/$hash{$key}/;
-        $text =~ s/ü/&uuml;/go;
-        $text =~ s/ö/&ouml;/go;
-        $text =~ s/ä/&auml;/go;
-        $text =~ s/ß/&szlig;/go;
-        $text =~ s/å/&aring;/go;
-        $text =~ s/æ/&aelig;/go;
-        $text =~ s/ø/&oslash;/go;
-        $text =~ s/Å/&Aring;/go;
-        $text =~ s/Æ/&AElig;/go;
-        $text =~ s/Ø/&Oslash;/go;
+
+        if ($self->{cfg}->{charset} eq "iso-8859-1" or $self->{cfg}->{charset} eq "iso-8859-15") {
+            $text =~ s/ü/&uuml;/go;
+            $text =~ s/ö/&ouml;/go;
+            $text =~ s/ä/&auml;/go;
+            $text =~ s/ß/&szlig;/go;
+            $text =~ s/å/&aring;/go;
+            $text =~ s/æ/&aelig;/go;
+            $text =~ s/ø/&oslash;/go;
+            $text =~ s/Å/&Aring;/go;
+            $text =~ s/Æ/&AElig;/go;
+            $text =~ s/Ø/&Oslash;/go;
+        }
     }
 
     if ($text =~ /\[:[^:]*?:[^:]*?:[^:]*?:\]/o) {
@@ -1523,7 +1526,7 @@ sub _format_word
     # This function formats a word -- should ONLY be called on words used alone (EG: not whole line printed)
     my ($self, $word) = @_;
 
-    $word = htmlentities($word);
+    $word = htmlentities($word, $self->{cfg}->{charset});
     $word = $self->_replace_links($word);
     return $word;
 }
@@ -1557,7 +1560,7 @@ sub _format_line
             $line = '*** ' . $hashref->{nick} . ' changes topic to: ' . $hashref->{newtopic};
         }
     }
-    $line = htmlentities($line);
+    $line = htmlentities($line, $self->{cfg}->{charset});
     $line = $self->_replace_links($line);
     return $line;
 }