X-Git-Url: https://git.distorted.org.uk/~mdw/odin-cgi/blobdiff_plain/be24e9afafe0d740652d962fd5531de901a9cd09..3300e9a2ef069dcea086ac6e510dd6540cd9fc82:/mason/pastebin/dhandler?ds=sidebyside diff --git a/mason/pastebin/dhandler b/mason/pastebin/dhandler index 7014dca..85b7ef3 100644 --- a/mason/pastebin/dhandler +++ b/mason/pastebin/dhandler @@ -7,6 +7,13 @@ -path => "$Odin::PASTEBIN_PATH/", %attr; } + sub hasuff ($) { + my ($edit) = @_; + return $Odin::COOKIE{"odin-cookie-probe"} ? "" : "?honc=$edit"; + } + + Odin::bake_cookie $r, "odin-cookie-probe=t"; + my %props = ( lang => $lang, title => $title, content => Odin::tidy_pastebin_content $content @@ -21,8 +28,9 @@ $r->content_type("text/plain; charset=utf8"); $m->print($old{content}); } else { - $m->comp("%show", tag => $tag, %old, - edit => $Odin::COOKIE{"odin-handoff.$tag"}); + $edit = $Odin::COOKIE{"odin-handoff.$tag"}; + $m->comp("%show", tag => $tag, + honc => $honc, edit => $edit // $honc, %old); } } else { if ($op eq "del") { @@ -30,16 +38,19 @@ set_handoff_cookie $tag, "nil", -max_age => 5; $m->redirect("$Odin::PASTEBIN/"); } else { - my $editp = Odin::update_pastebin $tag, $edit, %props; set_handoff_cookie $tag, $edit; - if ($editp) { $m->redirect("$Odin::PASTEBIN/$tag"); } - else { $m->comp("%edit", tag => $tag, edit => $edit, %props); } + my $editp = Odin::update_pastebin $tag, $edit, %props; + if ($editp) { + $m->redirect("$Odin::PASTEBIN/$tag" . hasuff $edit); + } else { + $m->comp("%edit", tag => $tag, edit => $edit, %props); + } } } } elsif (defined $content) { ($tag, $edit) = Odin::new_pastebin %props; set_handoff_cookie $tag, $edit; - $m->redirect("$Odin::PASTEBIN/$tag"); + $m->redirect("$Odin::PASTEBIN/$tag" . hasuff $edit); } else { Odin::path_info($r) =~ m:/$: or $m->redirect("$Odin::PASTEBIN/", 301); @@ -52,6 +63,7 @@ $edit => undef $lang => undef $title => undef + $honc => undef $op => "edit" %#