Allow sticky entry to be cleared, and validate the ditemid.

        Patch by exor674. 

diffs (32 lines):

diff -r 099eae6312b4 -r 00ac7af96856 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm        Fri Sep 25 12:40:53 2009 -0500
+++ b/cgi-bin/LJ/User.pm        Fri Sep 25 14:05:21 2009 -0500
@@ -2210,16 +2210,26 @@ sub sticky_entry {
     my ( $u, $input ) = @_;
 
     if ( defined $input ) {
+        unless ( $input ) {
+            $u->set_prop( sticky_entry => '' );
+            return 1;
+        } 
         #also takes URL
         my $ditemid;
         if ( $input =~ m!/(\d+)\.html! ) {
-            $ditemid = $1
+            $ditemid = $1;
         } elsif ( $input =~ m!(\d+)! ) {
-            $ditemid = $1
+            $ditemid = $1;
         } else {
             return 0;
         }
+        
+        # Validate the entry
+        my $item = LJ::Entry->new( $u, ditemid => $ditemid );
+        return 0 unless $item && $item->valid;
+        
         $u->set_prop( sticky_entry => $ditemid );
+        return 1;
     }
     return $u->prop( 'sticky_entry' );
 }
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to