Item14150: Reload of a page in the cache fails to recompute strikeone keys.
Priority: Urgent
Current State: Closed
Released In: 2.1.3
Target Release: patch
See
DirtyAreaTest
It appears that once a page with forms is cached, the only way to recompute the validation keys is to use the
refresh=cache
link. Even placing the form into a
<dirtyarea>
leaves stale validation keys in the generated HTML.
--
GeorgeClark - 29 Aug 2016
Here's a patch to try
diff --git a/core/lib/Foswiki/PageCache.pm b/core/lib/Foswiki/PageCache.pm
index c95a364..8ad3250 100644
--- a/core/lib/Foswiki/PageCache.pm
+++ b/core/lib/Foswiki/PageCache.pm
@@ -683,6 +683,14 @@ sub _handleDirtyArea {
$prefs->popTopicContext();
};
+ my $session = $Foswiki::Plugins::SESSION;
+ 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/<input type='hidden' name='validation_key' value='(\?.*?)' \/>/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 5441c32..3a83006 100644
--- a/core/lib/Foswiki/Validation.pm
+++ b/core/lib/Foswiki/Validation.pm
@@ -92,6 +92,15 @@ sub addValidationKey {
return "<input type='hidden' name='validation_key' value='?$nonce' />";
}
+sub updateValidationKey {
+ my ( $cgis, $context, $strikeone, $oldKey ) = @_;
+
+ # expire old key
+ expireValidationKeys($cgis, $oldKey);
+
+ return addValidationKey($cgis, $context, $strikeone);
+}
+
=begin TML