Hacky workaround. Deliberately add a new form tag to work around issues
with nested form tags which break the first poll form in the inbox (mostly
because you're not really supposed to nest form tags).
Patch by fu.
diffs (63 lines):
diff -r 5ce9fca619c5 -r 3c681263afac cgi-bin/LJ/Entry.pm
--- a/cgi-bin/LJ/Entry.pm Sat Jan 01 00:05:39 2011 -0600
+++ b/cgi-bin/LJ/Entry.pm Sat Jan 01 18:27:25 2011 +0800
@@ -734,7 +734,7 @@ sub event_html
my $event = $self->{event};
LJ::CleanHTML::clean_event(\$event, $opts);
- LJ::expand_embedded($self->{u}, $self->ditemid, LJ::User->remote, \$event);
+ LJ::expand_embedded($self->{u}, $self->ditemid, LJ::User->remote, \$event,
sandbox => $opts->{sandbox} );
return $event;
}
@@ -2156,7 +2156,7 @@ sub item_link
sub expand_embedded {
my ($u, $ditemid, $remote, $eventref, %opts) = @_;
- LJ::Poll->expand_entry($eventref) unless $opts{preview};
+ LJ::Poll->expand_entry( $eventref, %opts ) unless $opts{preview};
LJ::EmbedModule->expand_entry($u, $eventref, %opts);
LJ::Hooks::run_hooks("expand_embedded", $u, $ditemid, $remote, $eventref,
%opts);
}
diff -r 5ce9fca619c5 -r 3c681263afac cgi-bin/LJ/Event/JournalNewEntry.pm
--- a/cgi-bin/LJ/Event/JournalNewEntry.pm Sat Jan 01 00:05:39 2011 -0600
+++ b/cgi-bin/LJ/Event/JournalNewEntry.pm Sat Jan 01 18:27:25 2011 +0800
@@ -84,7 +84,9 @@ sub content {
return $entry->event_html( {
# double negatives, ouch!
ljcut_disable => ! $target->cut_inbox,
- cuturl => $entry->url } )
+ cuturl => $entry->url,
+ sandbox => 1,
+ } )
. $self->as_html_tags( $target )
. $self->as_html_actions;
diff -r 5ce9fca619c5 -r 3c681263afac cgi-bin/LJ/Poll.pm
--- a/cgi-bin/LJ/Poll.pm Sat Jan 01 00:05:39 2011 -0600
+++ b/cgi-bin/LJ/Poll.pm Sat Jan 01 18:27:25 2011 +0800
@@ -1311,7 +1311,7 @@ use Carp qw (croak);
# takes a scalarref to entry text and expands (lj-)poll tags into the polls
sub expand_entry {
- my ($class, $entryref) = @_;
+ my ( $class, $entryref, %opts ) = @_;
my $expand = sub {
my $pollid = $_[0] + 0;
@@ -1321,7 +1321,14 @@ sub expand_entry {
my $poll = LJ::Poll->new($pollid);
return "[Error: Invalid poll ID $pollid]" unless $poll && $poll->valid;
- return $poll->render;
+ if ( $opts{sandbox} ) {
+ # hacky. Basically, when we render an entry with a poll in a form
element
+ # the nested form from the poll wreaks havoc, breaking the first
poll form and (maybe) the outer form
+ # This deliberately adds a new form element, to make sure that our
poll form always works.
+ return "<form style='display: none'></form>" . $poll->render;
+ } else {
+ return $poll->render;
+ }
};
$$entryref =~ s/<(?:lj-)?poll-(\d+)>/$expand->($1)/eg if $$entryref;
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog