This repository was archived by the owner on Jan 6, 2026. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed
Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -257,8 +257,12 @@ sub add_paste {
257257 $lang = $self -> get_lang($lang );
258258 return 0 if $self -> error;
259259 }
260- if ( $expire !~ / ^(-1|[0-9]+)/ ) {
261- $self -> {error } = " Expire must be an integer or -1" ;
260+
261+ # Enforce 90 days max expiration (7776000 seconds)
262+ my $max_expire = 7776000;
263+
264+ if ( $expire !~ / ^[0-9]+$ / || $expire > $max_expire ) {
265+ $self -> {error } = " Expire must be an integer <= $max_expire (90 days)" ;
262266 return 0;
263267 }
264268
Original file line number Diff line number Diff line change @@ -81,12 +81,21 @@ sub startup {
8181
8282 $self -> helper( paste_model => sub { return $paste } );
8383 $self -> helper( tt => sub { return $tt } );
84+
85+ # Periodic cleanup (every hour)
86+ Mojo::IOLoop-> recurring(
87+ 3600 => sub {
88+ $self -> log -> debug(" Running scheduled paste cleanup..." );
89+ $paste -> cleanup_expired;
90+ }
91+ );
92+
8493 $self -> helper(
8594 render_tt => sub {
8695 my ( $c , $template , $vars ) = @_ ;
8796 my $output = ' ' ;
8897 local %ENV = %{ $c -> req-> env }; # TT CGI plugin expects %ENV
89- $c -> paste_model -> cleanup_expired;
98+
9099 my $user_pastes = [];
91100 if ( $c -> current_user ) {
92101 my $sid = Digest::SHA::sha1_hex( $c -> current_user-> {id } );
Original file line number Diff line number Diff line change 2626</ select >
2727< label for ="expire "> < b > Expiration</ b > </ label >
2828< select name ="expire " id ="expire ">
29- < option value ="-1 "> Never</ option >
3029< option value ="7776000 "> 90d</ option >
3130< option value ="259200 "> 3d</ option >
3231< option value ="86400 " selected > 24h</ option >
You can’t perform that action at this time.
0 commit comments