[dw-free] autoclose unclosed <cut> tag in xposted entries before xpost footer is added
[commit: http://hg.dwscoalition.org/dw-free/rev/36526b18693a]
http://bugs.dwscoalition.org/show_bug.cgi?id=2033
Automatically close cut tags before the end of an entry so we always show
the crosspost footer.
Patch by
afuna.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2033
Automatically close cut tags before the end of an entry so we always show
the crosspost footer.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/DW/External/XPostProtocol/LJXMLRPC.pm
-------------------------------------------------------------------------------- diff -r 035d70a5bec8 -r 36526b18693a cgi-bin/DW/External/XPostProtocol/LJXMLRPC.pm --- a/cgi-bin/DW/External/XPostProtocol/LJXMLRPC.pm Tue Nov 10 03:47:35 2009 +0000 +++ b/cgi-bin/DW/External/XPostProtocol/LJXMLRPC.pm Tue Nov 10 03:49:55 2009 +0000 @@ -423,6 +423,9 @@ sub clean_lj_tags { 'raw-code' => 'lj-raw' ); + # keep track of unclosed tags + my %opencount; + # this is mostly gakked from cgi-bin/cleanhtml.pl (LJ::CleanHTML) # go throught each token. @@ -453,6 +456,8 @@ sub clean_lj_tags { } $newdata .= " /" if $slashclose; $newdata .= ">"; + + $opencount{$tag}++ unless $slashclose; } elsif ($tag eq 'lj' || $tag eq 'user') { my $user = $hash->{user} = exists $hash->{name} ? $hash->{name} : exists $hash->{user} ? $hash->{user} : @@ -492,12 +497,14 @@ sub clean_lj_tags { } else { # if no change was necessary $newdata .= $token->[4]; + $opencount{$token->[1]}++; next TOKEN; } } elsif ($type eq "E") { if ($update_tags{$token->[1]}) { $newdata .= "</" . $update_tags{$token->[1]} . ">"; + $opencount{$update_tags{$token->[1]}}--; } else { $newdata .= $token->[2]; } @@ -516,6 +523,8 @@ sub clean_lj_tags { } } # end while + # explicitly close any cuts + $newdata .= "</lj-cut>" if $opencount{'lj-cut'}; $$entry_text_ref = $newdata; return undef; } --------------------------------------------------------------------------------