Committer: sbelyaev
LJSV-1286: Attribute source_user accepts current user. U trunk/cgi-bin/LJ/EmbedModule.pm U trunk/htdocs/update.bml
Modified: trunk/cgi-bin/LJ/EmbedModule.pm =================================================================== --- trunk/cgi-bin/LJ/EmbedModule.pm 2011-08-25 09:19:11 UTC (rev 19843) +++ trunk/cgi-bin/LJ/EmbedModule.pm 2011-08-25 09:20:43 UTC (rev 19844) @@ -126,32 +126,32 @@ ) . ">" . $opts{expand_to_link}->{caption} . "</a>"; } elsif ($opts{get_video_id}) { - my $code = $class->module_content(moduleid => $attrs{id}, journalid => $journal->id); + my $code = $class->module_content(moduleid => $attrs{id}, journalid => $journal->id); my $out= '<lj-embed id="'. $attrs{id} .'" '; # LJSUP-8992 if ($code =~ m!src=["']?http://www\.youtube\.com/(?:v|embed)/([\w\d\_\-]+)['"]?!) { $out .= 'vid="'.$1.'" source="youtube" '; - } elsif ($code =~ m!src=["']?http://player\.vimeo\.com/video/(\d+)[?'"]?! || + } elsif ($code =~ m!src=["']?http://player\.vimeo\.com/video/(\d+)[?'"]?! || $code =~ m!=["']?http://vimeo\.com/moogaloop\.swf\?[\d\w\_\-\&\;\=]*clip_id=(\d+)[&'"]?! ) { $out .= 'vid="'.$1.'" source="vimeo" '; } elsif ($code =~ m!=["']?http://video\.rutube\.ru/([\dabcdef]+)['"]?!) { $out .= 'vid="'.$1.'" source="rutube" '; } elsif ($code =~ m!=["']?http://static\.video\.yandex\.ru/([\d\w\/\-\_\.]+)['"]?!) { - $out .= 'vid="'.$1.'" source="yandex" '; + $out .= 'vid="'.$1.'" source="yandex" '; } elsif ($code =~ m!http://img\.mail\.ru.+movieSrc=([\w\d\/\_\-\.]+)["']?!) { $out .= 'vid="'.$1.'" source="mail.ru" '; } elsif ($code =~ m!http://(vkontakte\.ru|vk\.com)/video_ext!) { $out .= 'source="'.$1.'" '; my %fields = ($code =~ /(oid|id|hash)=([\dabcdef]+)/gm); $fields{vid} = delete $fields{id}; - $out .= $_.'="'.$fields{$_}.'" ' foreach (keys %fields); + $out .= $_.'="'.$fields{$_}.'" ' foreach (keys %fields); } $out .= '/>'; return $out; - + } else { @opts{qw /width height/} = @attrs{qw/width height/}; return $class->module_iframe_tag($journal, $attrs{id}, %opts) @@ -211,7 +211,7 @@ $tag = lc $tag; my $newstate = undef; my $reconstructed = $class->reconstruct($token); - + if ($state == REGULAR) { if ($tag eq 'lj-embed' && $type eq 'S' && ! $attr->{'/'}) { # <lj-embed ...>, not self-closed @@ -225,8 +225,13 @@ $attr->{'source_user'} && $attr->{'/'}) { my $u = LJ::load_user($attr->{'source_user'}); - if ($u) { + if ($journal->equals($u)) { + $newstate = EXPLICIT; # save embed id, width and height if they do exist in attributes + $embed_attrs{id} = $attr->{id} if $attr->{id}; + $embed_attrs{width} = ($attr->{width} > MAX_WIDTH ? MAX_WIDTH : $attr->{width}) if $attr->{width}; + $embed_attrs{height} = ($attr->{height} > MAX_HEIGHT ? MAX_HEIGHT : $attr->{height}) if $attr->{height}; + } else { $newstate = REGULAR; $embed = $class->module_content( moduleid => $attr->{id}, journalid => $u->id ); @@ -240,6 +245,7 @@ $embed_attrs{height} = $attr->{height} > MAX_HEIGHT ? MAX_HEIGHT : $attr->{height}; } } + } } } elsif (($tag eq 'object' || $tag eq 'embed' || $tag eq 'iframe') && $type eq 'S') { # <object> or <embed> @@ -528,10 +534,10 @@ $selfclose = 1; next; } - + ## Remove "data" attribute from <object data="..."> constructs. - ## Right now attribute is silently dropped. - ## TODO: pass a flag to outer scope that it was dropped, so that + ## Right now attribute is silently dropped. + ## TODO: pass a flag to outer scope that it was dropped, so that ## ljprotocol can notify user by throwing an error. if ($tag eq 'object' && $name eq 'data') { next; Modified: trunk/htdocs/update.bml =================================================================== --- trunk/htdocs/update.bml 2011-08-25 09:19:11 UTC (rev 19843) +++ trunk/htdocs/update.bml 2011-08-25 09:20:43 UTC (rev 19844) @@ -28,7 +28,7 @@ $$body = "<?badinput?>"; return; } - + ## This header is to pass page content through IE8 XSS Filter. ## See also htdocs/preview/entry.bml. LJ::Request->header_out("X-XSS-Protection" => 0); @@ -48,7 +48,7 @@ # get remote and see if they can post right now my $remote = LJ::get_remote(); - + # Should we show try and buy my $show_trynbuy = LJ::TryNBuy->can_enable($remote) || LJ::TryNBuy->active($remote); @@ -155,7 +155,7 @@ my $text = LJ::Widget::QotD->qotd_display_embed( questions => [ $qotd ], form_disabled => 1 ); $$head .= "<script type=\"text/javascript\">LiveJournal.qotdText = \"" . LJ::ejs($text) . "\";</script>"; } - + if ($url) { ## currently, the URL is for YouTube only. ## in future support for other quick embeds will be added. @@ -183,12 +183,9 @@ unless ($event) { $event = $entry->event_raw; my $journalu = $entry->journal; + LJ::EmbedModule->add_user_to_embed($journalu, \$event); - if (!$journalu->equals($remote)) { - LJ::EmbedModule->add_user_to_embed($journalu, \$event); - } - - $event = LJ::Lang::ml("repost.wrapper", { + $event = LJ::Lang::ml("repost.wrapper", { username => $entry->poster->username, url => $entry->url, subject => $subject, @@ -197,7 +194,6 @@ $reposted_from = $entry->url; } } - } # try to call a hook to fill in the fields @@ -232,7 +228,7 @@ my $errors = {}; my $showform = $POST{'showform'} || $auth_missing; # show entry form my $preview = $POST{'action:preview'}; - + # are we spellchecking before we post? my $did_spellcheck; my $spellcheck_html; if ($LJ::SPELLER && $POST{'action:spellcheck'}) { @@ -315,7 +311,7 @@ $entry->{prop_opt_default_nocomments} = $remote->prop('opt_showtalklinks'); $entry->{prop_last_fm_user} = $remote->prop('last_fm_user'); } - + if ($did_post) { $entry->{$_} = $POST{$_} foreach keys %POST; @@ -351,7 +347,7 @@ } $$body .= "\n\n<form method='post' action='update.bml$getextra' id='updateForm' name='updateForm'>\n\n"; - + $$body .= LJ::form_auth(); if ($reposted_from) { @@ -374,7 +370,6 @@ </script> LIKE_FAQ $$body .= $js; - $$body .= LJ::Widget::SettingWindow->render; return;