Ensure form tokens are not longer than allowed

Bug: T295940
Change-Id: I4e3fd5d3ef21274b104c4d22e3bab11043d61334
This commit is contained in:
Bartosz Dziewoński 2021-11-17 23:53:38 +01:00
parent 45ef474109
commit 72f806829c

View file

@ -533,7 +533,9 @@ ReplyWidget.prototype.afterSetup = function () {
ReplyWidget.prototype.getFormToken = function () {
var formToken = this.storage.get( this.storagePrefix + '/formToken' );
if ( !formToken ) {
formToken = Math.random().toString( 36 ).slice( 2 );
// See ApiBase::PARAM_MAX_CHARS in ApiDiscussionToolsEdit.php
var maxLength = 16;
formToken = Math.random().toString( 36 ).slice( 2, maxLength + 2 );
this.storage.set( this.storagePrefix + '/formToken', formToken );
}
return formToken;