chiark
/
gitweb
/
~mdw
/
odin-cgi
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib/Odin.pm: Provide substitutions on mail recipient addresses.
[odin-cgi]
/
mason
/
pastebin
/
dhandler
diff --git
a/mason/pastebin/dhandler
b/mason/pastebin/dhandler
index 7f6ea24dcb7b0f3c207583467ca177e1216a34e6..85839815ddd55acf775ce292832dae4852200d18 100644
(file)
--- a/
mason/pastebin/dhandler
+++ b/
mason/pastebin/dhandler
@@
-7,6
+7,13
@@
-path => "$Odin::PASTEBIN_PATH/", %attr;
}
-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
my %props = (
lang => $lang, title => $title,
content => Odin::tidy_pastebin_content $content
@@
-22,7
+29,8
@@
$m->print($old{content});
} else {
$edit = $Odin::COOKIE{"odin-handoff.$tag"};
$m->print($old{content});
} else {
$edit = $Odin::COOKIE{"odin-handoff.$tag"};
- $m->comp("%show", tag => $tag, edit => $edit, %old);
+ $m->comp("%show", tag => $tag,
+ honc => $honc, edit => $edit // $honc, %old);
}
} else {
if ($op eq "del") {
}
} else {
if ($op eq "del") {
@@
-32,14
+40,17
@@
} else {
set_handoff_cookie $tag, $edit;
my $editp = Odin::update_pastebin $tag, $edit, %props;
} else {
set_handoff_cookie $tag, $edit;
my $editp = Odin::update_pastebin $tag, $edit, %props;
- if ($editp) { $m->redirect("$Odin::PASTEBIN/$tag"); }
- else { $m->comp("%edit", tag => $tag, edit => $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;
}
}
} 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);
} else {
Odin::path_info($r) =~ m:/$:
or $m->redirect("$Odin::PASTEBIN/", 301);
@@
-52,6
+63,7
@@
$edit => undef
$lang => undef
$title => undef
$edit => undef
$lang => undef
$title => undef
+ $honc => undef
$op => "edit"
</%args>
%#
$op => "edit"
</%args>
%#
@@
-64,8
+76,17
@@
tag ‘<% $tag %>’ not found
</%args>
</%def>
%#
</%args>
</%def>
%#
+<%def .badpaste>
+<&| SELF:error, status => 400 &>\
+invalid paste content
+</&>
+<%args>
+ $tag
+</%args>
+</%def>
+%#
<%def .badhash>
<%def .badhash>
-<&| SELF:error, status => 40
4
&>\
+<&| SELF:error, status => 40
3
&>\
incorrect edit key
</&>
<%args>
incorrect edit key
</&>
<%args>