fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-07-29 05:51 am

[dw-free] Long tags get truncated silently

[commit: http://hg.dwscoalition.org/dw-free/rev/be9772bf3332]

http://bugs.dwscoalition.org/show_bug.cgi?id=1960

Remove trailing spaces after the tags have been truncated, to avoid
problems.

Patch by [personal profile] cpm.

Files modified:
  • cgi-bin/LJ/Tags.pm
  • cgi-bin/LJ/User.pm
  • cgi-bin/ljlib.pl
--------------------------------------------------------------------------------
diff -r d64499e9d24f -r be9772bf3332 cgi-bin/LJ/Tags.pm
--- a/cgi-bin/LJ/Tags.pm	Wed Jul 28 22:29:11 2010 -0700
+++ b/cgi-bin/LJ/Tags.pm	Wed Jul 28 22:51:14 2010 -0700
@@ -642,6 +642,7 @@ sub is_valid_tagstring {
         $tag =~ s/\s+/ /g; # condense multiple spaces to a single space
         $tag = LJ::text_trim($tag, LJ::BMAX_KEYWORD, LJ::CMAX_KEYWORD);
         $tag = LJ::utf8_lc( $tag );
+        $tag = LJ::trim( $tag ); # after trucating, there may be a trailing space
         return $tag;
     };
 
diff -r d64499e9d24f -r be9772bf3332 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Wed Jul 28 22:29:11 2010 -0700
+++ b/cgi-bin/LJ/User.pm	Wed Jul 28 22:51:14 2010 -0700
@@ -5921,7 +5921,7 @@ sub get_keyword_id
 
     # setup the keyword for use
     return 0 unless $kw =~ /\S/;
-    $kw = LJ::text_trim( $kw, LJ::BMAX_KEYWORD, LJ::CMAX_KEYWORD );
+    $kw = LJ::trim( LJ::text_trim( $kw, LJ::BMAX_KEYWORD, LJ::CMAX_KEYWORD ) );
 
     # get the keyword and insert it if necessary
     my $kwid = $u->selectrow_array( 'SELECT kwid FROM userkeywords WHERE userid = ? AND keyword = ?',
diff -r d64499e9d24f -r be9772bf3332 cgi-bin/ljlib.pl
--- a/cgi-bin/ljlib.pl	Wed Jul 28 22:29:11 2010 -0700
+++ b/cgi-bin/ljlib.pl	Wed Jul 28 22:51:14 2010 -0700
@@ -1550,7 +1550,7 @@ sub get_sitekeyword_id {
 
     # setup the keyword for use
     return 0 unless $kw =~ /\S/;
-    $kw = LJ::text_trim( LJ::trim( $kw ), LJ::BMAX_SITEKEYWORD, LJ::CMAX_SITEKEYWORD );
+    $kw = LJ::trim( LJ::text_trim( LJ::trim( $kw ), LJ::BMAX_SITEKEYWORD, LJ::CMAX_SITEKEYWORD ) );
 
     # get the keyword and insert it if necessary
     my $dbr = LJ::get_db_reader();
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org