juks (juks) wrote in changelog,
juks
juks
changelog

[livejournal] r18010: LJSUP-7307 Rules of post parsing

Committer: iaskarov
LJSUP-7307 Rules of post parsing
U   trunk/cgi-bin/LJ/Text.pm
Modified: trunk/cgi-bin/LJ/Text.pm
===================================================================
--- trunk/cgi-bin/LJ/Text.pm	2011-01-12 04:04:13 UTC (rev 18009)
+++ trunk/cgi-bin/LJ/Text.pm	2011-01-12 05:26:15 UTC (rev 18010)
@@ -257,21 +257,22 @@
 
         $str = $remove_last_word->($str);
         $remainder = substr($original_string, $class->byte_len($str));
-        
+
         $str .= $ellipsis;
     }
-	
+
     if ($chars && $class->char_len($str) > $chars) {
         my $chars_trunc = $chars - $class->char_len($ellipsis);
+
         $str = $class->truncate(
             'str' => $str,
             'chars' => $chars_trunc + 1
         );
-       
-        my $add_space = (substr($str, $chars_trunc, 1) =~ /\s/);
 
+        my $add_space = (substr(decode_utf8($str), $chars_trunc, 1) =~ /\s/);
+
         $str = $remove_last_word->($str);
- 
+
         # What kind af moron one has to be to come up with this kind of logic to be implemented? 
         if($add_space) {
             $str .= ' ';
@@ -291,7 +292,8 @@
         }
 
         $remainder = substr($original_string, $class->byte_len($str));
-
+        
+        $str .= ' ' if($add_space && $str =~ /\S$/);
         $str .= $ellipsis;
     } elsif($force_ellipsis) {
         $str .= ' ' if($str =~ /\S$/);

Tags: juks, livejournal, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments