[dw-free] LJ chokes on user tags in our feeds
[commit: http://hg.dwscoalition.org/dw-free/rev/223133988313]
http://bugs.dwscoalition.org/show_bug.cgi?id=481
Don't set the class on outgoing ljuser HTML. This is to work around a
presentation bug on LJ sites as well as to preserve our variable site tags.
Patch by
afuna.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=481
Don't set the class on outgoing ljuser HTML. This is to work around a
presentation bug on LJ sites as well as to preserve our variable site tags.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/DW/External/User.pm
- cgi-bin/LJ/User.pm
- cgi-bin/cleanhtml.pl
- cgi-bin/ljfeed.pl
-------------------------------------------------------------------------------- diff -r 87229f3e4dff -r 223133988313 cgi-bin/DW/External/User.pm --- a/cgi-bin/DW/External/User.pm Mon Apr 06 05:13:35 2009 +0000 +++ b/cgi-bin/DW/External/User.pm Mon Apr 06 05:16:34 2009 +0000 @@ -59,14 +59,15 @@ sub site { # return the ljuser_display block sub ljuser_display { - my $self = $_[0]; + my ( $self, %opts ) = @_; my $user = $self->user; my $profile_url = $self->site->profile_url( $self ); my $journal_url = $self->site->journal_url( $self ); my $badge_image_url = $self->site->badge_image_url( $self ); + my $display_class = $opts{no_ljuser_class} ? "" : "class='ljuser'"; - return "<span class='ljuser' lj:user='$user' style='white-space: nowrap;'><a href='$profile_url'>" . + return "<span $display_class lj:user='$user' style='white-space: nowrap;'><a href='$profile_url'>" . "<img src='$badge_image_url' alt='[info]' style='vertical-align: bottom; border: 0; padding-right: 1px;' />" . "</a><a href='$journal_url'><b>$user</b></a></span>"; } diff -r 87229f3e4dff -r 223133988313 cgi-bin/LJ/User.pm --- a/cgi-bin/LJ/User.pm Mon Apr 06 05:13:35 2009 +0000 +++ b/cgi-bin/LJ/User.pm Mon Apr 06 05:16:34 2009 +0000 @@ -2256,6 +2256,7 @@ sub ljuser_display { my $strike = $opts->{'del'} ? ' text-decoration: line-through;' : ''; my $profile_url = $opts->{'profile_url'} || ''; my $journal_url = $opts->{'journal_url'} || ''; + my $display_class = $opts->{no_ljuser_class} ? "" : "class='ljuser'"; my ($url, $name); @@ -2287,7 +2288,7 @@ sub ljuser_display { my $profile = $profile_url ne '' ? $profile_url : "$LJ::SITEROOT/userinfo.bml?userid=$u->{userid}&t=I$andfull"; - return "<span class='ljuser' lj:user='$name' style='white-space: nowrap;$strike'><a href='$profile'><img src='$imgurl' alt='[info]' width='$width' height='$height' style='vertical-align: bottom; border: 0; padding-right: 1px;' /></a><a href='$url' rel='nofollow'><b>$name</b></a></span>"; + return "<span $display_class lj:user='$name' style='white-space: nowrap;$strike'><a href='$profile'><img src='$imgurl' alt='[info]' width='$width' height='$height' style='vertical-align: bottom; border: 0; padding-right: 1px;' /></a><a href='$url' rel='nofollow'><b>$name</b></a></span>"; } else { return "<b>????</b>"; @@ -6587,13 +6588,13 @@ sub get_timezone { # </LJFUNC> sub ljuser { - my $user = shift; - my $opts = shift; + my ( $user, $opts ) = @_; my $andfull = $opts->{'full'} ? "?mode=full" : ""; my $img = $opts->{'imgroot'} || $LJ::IMGPREFIX; my $profile_url = $opts->{'profile_url'} || ''; my $journal_url = $opts->{'journal_url'} || ''; + my $display_class = $opts->{no_ljuser_class} ? "" : "class='ljuser'"; my $profile; my $make_tag = sub { @@ -6614,7 +6615,7 @@ sub ljuser $profile = $profile_url ne '' ? $profile_url : $profile . $andfull; $url = $journal_url ne '' ? $journal_url : $url; - return "<span class='ljuser' lj:user='$user' style='white-space: nowrap;$strike'><a href='$profile'><img src='$img/$fil' alt='[info]' width='$x' height='$y' style='vertical-align: bottom; border: 0; padding-right: 1px;' /></a><a href='$url'$link_color>$ljusername</a></span>"; + return "<span $display_class lj:user='$user' style='white-space: nowrap;$strike'><a href='$profile'><img src='$img/$fil' alt='[info]' width='$x' height='$y' style='vertical-align: bottom; border: 0; padding-right: 1px;' /></a><a href='$url'$link_color>$ljusername</a></span>"; }; my $u = isu($user) ? $user : LJ::load_user($user); diff -r 87229f3e4dff -r 223133988313 cgi-bin/cleanhtml.pl --- a/cgi-bin/cleanhtml.pl Mon Apr 06 05:13:35 2009 +0000 +++ b/cgi-bin/cleanhtml.pl Mon Apr 06 05:16:34 2009 +0000 @@ -63,6 +63,7 @@ package LJ::CleanHTML; # 'transform_embed_wmode' => <value>, # define a wmode value for videos (usually 'transparent' is the value you want) # 'blocked_links' => [ qr/evil\.com/, qw/spammer\.com/ ], # list of sites which URL's will be blocked # 'blocked_link_substitute' => 'http://domain.com/error.html' # blocked links will be replaced by this URL +# 'to_external_site' => 0, # flag for when the content is going to be fed to external sites, so it can be special-cased. e.g., feeds # }); sub helper_preload @@ -143,6 +144,7 @@ sub clean ($LJ::BLOCKED_LINK_SUBSTITUTE) ? $LJ::BLOCKED_LINK_SUBSTITUTE : '#'; my $suspend_msg = $opts->{'suspend_msg'} || 0; my $unsuspend_supportid = $opts->{'unsuspend_supportid'} || 0; + my $to_external_site = $opts->{to_external_site} || 0; my @canonical_urls; # extracted links my %action = (); @@ -497,7 +499,7 @@ sub clean # FIXME: need a textonly way of identifying users better? "user@LJ"? $newdata .= $user; } else { - $newdata .= $ext_u->ljuser_display; + $newdata .= $ext_u->ljuser_display( no_ljuser_class => $to_external_site ); } # if we hit the else, then we know that this user doesn't appear @@ -516,7 +518,7 @@ sub clean if ($opts->{'textonly'}) { $newdata .= $user; } else { - $newdata .= LJ::ljuser($user); + $newdata .= LJ::ljuser( $user, { no_ljuser_class => $to_external_site } ); } } else { $orig_user = LJ::no_utf8_flag($orig_user); @@ -852,7 +854,12 @@ sub clean if ( $eating_ljuser_span ) { if ( $tag eq "span" ) { $eating_ljuser_span = 0; - $newdata .= $opts->{'textonly'} ? $ljuser_text_node : LJ::ljuser($ljuser_text_node); + + if ( $opts->{textonly} ) { + $newdata .= $ljuser_text_node; + } else { + $newdata .= LJ::ljuser( $ljuser_text_node, { no_ljuser_class => $to_external_site } ); + } } next TOKEN; @@ -1325,6 +1332,7 @@ sub clean_event 'transform_embed_wmode' => $opts->{'transform_embed_wmode'}, 'suspend_msg' => $opts->{'suspend_msg'} ? 1 : 0, 'unsuspend_supportid' => $opts->{'unsuspend_supportid'}, + to_external_site => $opts->{to_external_site} ? 1 : 0, }); } diff -r 87229f3e4dff -r 223133988313 cgi-bin/ljfeed.pl --- a/cgi-bin/ljfeed.pl Mon Apr 06 05:13:35 2009 +0000 +++ b/cgi-bin/ljfeed.pl Mon Apr 06 05:16:34 2009 +0000 @@ -208,8 +208,12 @@ sub make_feed } LJ::CleanHTML::clean_event(\$event, - { 'wordlength' => 0, 'preformatted' => $logprops{$itemid}->{'opt_preformatted'}, 'cuturl' => $u->{'opt_synlevel'} eq 'ljcut' ? "$journalinfo->{link}$ditemid.html" : "" }); - + { + wordlength => 0, + preformatted => $logprops{$itemid}->{opt_preformatted}, + cuturl => $u->{opt_synlevel} eq 'ljcut' ? "$journalinfo->{link}$ditemid.html" : "", + to_external_site => 1, + }); # do this after clean so we don't have to about know whether or not # the event is preformatted if ($u->{'opt_synlevel'} eq 'summary') { --------------------------------------------------------------------------------