From 377070f12059e6fcb1bd595d6245f6dea00fe571 Mon Sep 17 00:00:00 2001 From: George Clark Date: Wed, 31 Aug 2016 10:10:52 -0400 Subject: [PATCH] Item14150: Recompute validation keys on cached pages Fix provided by MichaelDaum. Cached pages were keeping their original cached validation keys. Once they expired, it was impossible to submit forms on cached pages without refreshing the cache. --- core/lib/Foswiki/PageCache.pm | 8 ++++++++ core/lib/Foswiki/Validation.pm | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/core/lib/Foswiki/PageCache.pm b/core/lib/Foswiki/PageCache.pm index 5770a18e20..9c00fa9b86 100644 --- a/core/lib/Foswiki/PageCache.pm +++ b/core/lib/Foswiki/PageCache.pm @@ -681,6 +681,14 @@ sub _handleDirtyArea { $prefs->popTopicContext(); }; + my $request = $session->{request}; + my $context = $request->url( -full => 1, -path => 1, -query => 1 ) . time(); + my $cgis = $session->{users}->getCGISession(); + my $usingStrikeOne = $Foswiki::cfg{Validation}{Method} eq 'strikeone'; + + $text =~ +s//Foswiki::Validation::updateValidationKey($cgis, $context, $usingStrikeOne, $1)/gei; + #Foswiki::Func::writeDebug("out text='$text'") if TRACE; return $text; } diff --git a/core/lib/Foswiki/Validation.pm b/core/lib/Foswiki/Validation.pm index 5441c3278d..c4ae7c4591 100644 --- a/core/lib/Foswiki/Validation.pm +++ b/core/lib/Foswiki/Validation.pm @@ -92,6 +92,15 @@ sub addValidationKey { return ""; } +sub updateValidationKey { + my ( $cgis, $context, $strikeone, $oldKey ) = @_; + + # expire old key + expireValidationKeys( $cgis, $oldKey ); + + return addValidationKey( $cgis, $context, $strikeone ); +} + =begin TML ---++ StaticMethod generateValidationKey( $cgis, $context, $strikeone ) -> $nonce