Page Index Toggle Pages: 1 ReplyAdd Poll Send Topic
Normal Topic LivePreview chokes on character encoding detection (Read 3180 times)
 
Paste Member Name in Quick Reply Box Monni
Language
***
Offline


Min izāmō

Posts: 413
Location: Kaarina, Finland
Joined: Jul 16th, 2014
Gender: Male
Mood: Frustrated
Zodiac sign: Pisces
LivePreview chokes on character encoding detection
Aug 31st, 2014 at 10:06pm
Mark & QuoteQuote  
Code
Select All
 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 »  
Back to top
IP Logged
 
Paste Member Name in Quick Reply Box Monni
Language
***
Offline


Min izāmō

Posts: 413
Location: Kaarina, Finland
Joined: Jul 16th, 2014
Gender: Male
Mood: Frustrated
Zodiac sign: Pisces
Re: LivePreview chokes on character encoding detection
Reply #1 - Sep 1st, 2014 at 12:30am
Mark & QuoteQuote  
Part 2/2:
Code
Select All
 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 Smiley
  
Back to top
IP Logged
 
Paste Member Name in Quick Reply Box Monni
Language
***
Offline


Min izāmō

Posts: 413
Location: Kaarina, Finland
Joined: Jul 16th, 2014
Gender: Male
Mood: Frustrated
Zodiac sign: Pisces
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
Select All
 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);
  

  
Back to top
IP Logged
 
Paste Member Name in Quick Reply Box Dandello
Forum Administrator
YaBB Modder
*****
Offline


I love YaBB 2.7!

Posts: 2234
Location: The Land of YaBB
Joined: Feb 12th, 2014
Gender: Female
Mood: Annoyed
Zodiac sign: Virgo
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.  Tongue
  

Perfection is not possible. Excellence, however, is excellent.
Back to top
WWW  
IP Logged
 
Paste Member Name in Quick Reply Box Monni
Language
***
Offline


Min izāmō

Posts: 413
Location: Kaarina, Finland
Joined: Jul 16th, 2014
Gender: Male
Mood: Frustrated
Zodiac sign: Pisces
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.  Tongue


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 Wink
  
Back to top
IP Logged
 
Paste Member Name in Quick Reply Box Dandello
Forum Administrator
YaBB Modder
*****
Offline


I love YaBB 2.7!

Posts: 2234
Location: The Land of YaBB
Joined: Feb 12th, 2014
Gender: Female
Mood: Annoyed
Zodiac sign: Virgo
Re: LivePreview chokes on character encoding detection
Reply #5 - Sep 2nd, 2014 at 1:36pm
Mark & QuoteQuote  
Good job  Smiley
  

Perfection is not possible. Excellence, however, is excellent.
Back to top
WWW  
IP Logged
 
Paste Member Name in Quick Reply Box Monni
Language
***
Offline


Min izāmō

Posts: 413
Location: Kaarina, Finland
Joined: Jul 16th, 2014
Gender: Male
Mood: Frustrated
Zodiac sign: Pisces
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 Wink
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
ReplyAdd Poll Send Topic
Bookmarks: del.icio.us Digg Facebook Google LinkedIn reddit Twitter Yahoo
LivePreview chokes on character encoding detection

Please type the characters exactly as they appear in the image,
without the first 2 and last 2 characters.
The characters must be typed in the same order,
and they are case-sensitive.
Open Preview Preview

You can resize the textbox by dragging the right or bottom border.
Off Topic Comment Insert Spoiler
Insert Hyperlink Insert FTP Link Insert Image Insert E-mail Insert Media Insert Table Insert Table Row Insert Table Column Insert Horizontal Rule Insert Teletype Insert Code Insert Quote Edited Superscript Subscript Insert List /me - my name Insert Marquee Insert Timestamp No Parse
Bold Italicized Underline Insert Strikethrough Highlight
                       
Change Text Color
Insert Preformatted Text Left Align Centered Right Align
resize_wb
resize_hb







Max 5000 characters. Remaining characters:
Text size: %
More Smilies
View All Smilies
Collapse additional features Collapse/Expand additional features Smiley Wink Cheesy Grin Angry Sad Shocked Cool Huh Roll Eyes Tongue Embarrassed Lips Sealed Undecided Kiss Cry