Monni Language Offline Min izāmō Posts: 413 Location: Kaarina, Finland Joined: Jul 16th, 2014 Gender: Mood: Frustrated Zodiac sign: LivePreview chokes on character encoding detection Aug 31st, 2014 at 10:06pm Mark & QuoteQuote Code Index: cgi-bin/yabb2/Sources/LivePreview.pm =================================================================== --- cgi-bin/yabb2/Sources/LivePreview.pm (revision 1557) +++ cgi-bin/yabb2/Sources/LivePreview.pm (working copy) @@ -22,6 +22,9 @@ $livepreviewpmver = 'YaBB 2.6.0 $Revision$'; if ( $action eq 'detailedversion' ) { return 1; } use URI::Escape; +if ( $yymycharset ne 'UTF-8' ) { + use Encode; +} LoadCensorList(); guard(); if ( $enable_ubbc ) { @@ -35,6 +38,9 @@ $FORM{'message'} =~ s/\r//gsm; $message = $FORM{'message'}; uri_unescape($message); + if ( $yymycharset ne 'UTF-8' ) { + $message = decode_utf8($message); + } $message =~ s/\[ch8203\]//igsm; $message =~ s/\//igsm; FromChars($message); @@ -58,6 +64,9 @@ $message = Censor($message); $csubject = $FORM{'subject'}; uri_unescape($csubject); + if ( $yymycharset ne 'UTF-8' ) { + $csubject = decode_utf8($csubject); + } $csubject =~ s/[\r\n]//gsm; FromChars($csubject); $convertstr = $csubject; @@ -70,11 +79,19 @@ liveimage_resize(); $myname = $FORM{'guestname'}; uri_unescape($myname); + if ( $yymycharset ne 'UTF-8' ) { + $myname = decode_utf8($myname); + } $myname =~ s/[\r\n]//gsm; FromChars($myname); ToHTML($myname); ToChars($myname); $myname = Censor($myname); + if ( $yymycharset ne 'UTF-8' ) { + $csubject = encode_utf8($csubject); + $message = encode_utf8($message); + $myname = encode_utf8($message); + } print "Content-type: application/x-www-form-urlencoded\n\n" or croak "$croak{'print'} content-type"; print qq~$csubject|$message|$myname~ or croak "$croak{'print'}"; @@ -87,6 +104,9 @@ $FORM{'message'} =~ s/\r//gxsm; $message = $FORM{'message'}; uri_unescape($message); + if ( $yymycharset ne 'UTF-8' ) { + $message = decode_utf8($message); + } $message =~ s/\[ch8203\]//igsm; $message =~ s/\//igsm; FromChars($message); @@ -111,6 +131,9 @@ $message = Censor($message); $csubject = $FORM{'subject'}; uri_unescape($csubject); + if ( $yymycharset ne 'UTF-8' ) { + $csubject = decode_utf8($csubject); + } $csubject =~ s/[\r\n]//gsm; FromChars($csubject); $convertstr = $csubject; @@ -143,6 +166,9 @@ liveimage_resize(); + if ( $yymycharset ne 'UTF-8' ) { + $messageblock = encode_utf8($messageblock); + } print "Content-type: application/x-www-form-urlencoded\n\n" or croak "$croak{'print'} content-type"; print qq~$messageblock\n~ or croak "$croak{'print'} messageblock"; @@ -152,9 +178,12 @@ sub DoLiveCal { LoadLanguage('EventCal'); - $FORM{'message'} =~ s/\r//gxsm; $message = $FORM{'message'}; uri_unescape($message); + if ( $yymycharset ne 'UTF-8' ) { + $message = decode_utf8($message); + } + $message =~ s/\r//gxsm; $message =~ s/\[ch8203\]//igsm; $message =~ s/\//igsm; FromChars($message); @@ -181,6 +210,9 @@ CountChars(); $myname = $FORM{'guestname'}; uri_unescape($myname); + if ( $yymycharset ne 'UTF-8' ) { + $myname = decode_utf8($myname); + } $myname =~ s/[\r\n]//gsm; FromChars($myname); ToHTML($myname); @@ -198,6 +230,12 @@ $mybtime = stringtotime(qq~$d_mon/$d_day/$d_year~); $mybtimein = timeformat($mybtime); $cdate = dtonly($mybtimein); + if ( $yymycharset ne 'UTF-8' ) { + $message = encode_utf8($message); + $myname = encode_utf8($myname); + $cdate = encode_utf8($cdate); + $txt_icon = encode_utf8($txt_icon); + } print "Content-type: application/x-www-form-urlencoded\n\n" or croak "$croak{'print'} content-type"; print qq~$message|$myname|$cdate|$txt_icon|$mycal_type~ To be continued on next post... « Last Edit: Sep 1st, 2014 at 12:29am by Monni » GTalk Skype/VoIP Facebook Twitter YouTube ICQ IP Logged
Monni Language Offline Min izāmō Posts: 413 Location: Kaarina, Finland Joined: Jul 16th, 2014 Gender: Mood: Frustrated Zodiac sign: Re: LivePreview chokes on character encoding detection Reply #1 - Sep 1st, 2014 at 12:30am Mark & QuoteQuote Part 2/2: Code Index: cgi-bin/yabb2/Sources/YaBBC.pm =================================================================== --- cgi-bin/yabb2/Sources/YaBBC.pm (revision 1557) +++ cgi-bin/yabb2/Sources/YaBBC.pm (working copy) @@ -20,9 +20,6 @@ LoadLanguage('Post'); $yyYaBBCloaded = 1; -if ( $yymycharset ne 'UTF-8' ) { - use HTML::Entities; -} sub MakeSmileys { my ($inp) = @_; @@ -106,7 +103,7 @@ else { $fqauthor = decloak($qauthor); - # if all fails it is a non existing real name so decode and asign as screenname + # if all fails it is a non-existing real name so decode and assign as screenname } } else { @@ -132,9 +129,6 @@ $qmessage = parseimgflash($qmessage); $qdate = timeformat($qdate,0,0,0,1); # generates also the global variable $daytxt - if ( $yymycharset ne 'UTF-8' ) { - encode_entities($qdate, "\200-\377"); # escape high ASCII - } $cssbg = $ycssvalues[ ( $ycsscounter % $ycssnum ) ]; $ycsscounter++; if ( $fqauthor eq q{} || $qlink eq q{} || $qdate eq q{} ) { This fixes it good... No more hacks GTalk Skype/VoIP Facebook Twitter YouTube ICQ IP Logged
Monni Language Offline Min izāmō Posts: 413 Location: Kaarina, Finland Joined: Jul 16th, 2014 Gender: Mood: Frustrated Zodiac sign: Re: LivePreview chokes on character encoding detection Reply #2 - Sep 2nd, 2014 at 3:52am Mark & QuoteQuote I think you messed up one line in the patch: Code Index: cgi-bin/yabb2/Sources/LivePreview.pm =================================================================== --- cgi-bin/yabb2/Sources/LivePreview.pm (revision 1559) +++ cgi-bin/yabb2/Sources/LivePreview.pm (working copy) @@ -80,7 +80,7 @@ $myname = $FORM{'guestname'}; uri_unescape($myname); if ( $yymycharset ne 'UTF-8' ) { - $csubject = decode_utf8($myname); + $myname = decode_utf8($myname); } $myname =~ s/[\r\n]//gsm; FromChars($myname); GTalk Skype/VoIP Facebook Twitter YouTube ICQ IP Logged
Dandello Forum AdministratorYaBB Modder Offline I love YaBB 2.7! Posts: 2235 Location: The Land of YaBB Joined: Feb 12th, 2014 Gender: Mood: Annoyed Zodiac sign: Re: LivePreview chokes on character encoding detection Reply #3 - Sep 2nd, 2014 at 4:29am Mark & QuoteQuote Thanks - that's what happens when I hurry. Perfection is not possible. Excellence, however, is excellent. WWW IP Logged
Monni Language Offline Min izāmō Posts: 413 Location: Kaarina, Finland Joined: Jul 16th, 2014 Gender: Mood: Frustrated Zodiac sign: Re: LivePreview chokes on character encoding detection Reply #4 - Sep 2nd, 2014 at 9:28am Mark & QuoteQuote Dandello wrote on Sep 2nd, 2014 at 4:29am:Thanks - that's what happens when I hurry. I know... It took me a while after I upgraded Perl to figure out what was the root cause of the encoding issues... Then it was just cleaning up the code and redoing LivePreview.pm to do the conversion the right way GTalk Skype/VoIP Facebook Twitter YouTube ICQ IP Logged
Dandello Forum AdministratorYaBB Modder Offline I love YaBB 2.7! Posts: 2235 Location: The Land of YaBB Joined: Feb 12th, 2014 Gender: Mood: Annoyed Zodiac sign: Re: LivePreview chokes on character encoding detection Reply #5 - Sep 2nd, 2014 at 1:36pm Mark & QuoteQuote Good job Perfection is not possible. Excellence, however, is excellent. WWW IP Logged
Monni Language Offline Min izāmō Posts: 413 Location: Kaarina, Finland Joined: Jul 16th, 2014 Gender: Mood: Frustrated Zodiac sign: Re: LivePreview chokes on character encoding detection Reply #6 - Sep 2nd, 2014 at 4:41pm Mark & QuoteQuote I promised I won't give up until I find where it goes wrong GTalk Skype/VoIP Facebook Twitter YouTube ICQ IP Logged