Skip to content

Commit 6c2e2c0

Browse files
committed
Scribunto: Add token param since MW 1.40.0-wmf.5.
1 parent 8bc63cb commit 6c2e2c0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

WikiClientLibrary/Scribunto/ScribuntoConsole.cs

+2
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ internal static async Task<ScribuntoEvaluationResult> InvokeApiAsync(WikiSite si
180180
jresult = await site.InvokeMediaWikiApiAsync(new MediaWikiFormRequestMessage(new
181181
{
182182
action = "scribunto-console",
183+
// Since wikimedia/mediawiki-extensions-Scribunto@0f2585244cbdc22580cc431745328a8f1fb270bd (1.40.0-wmf.5)
184+
token = site.SiteInfo.Version.Above(1, 40, 0, MediaWikiDevChannel.Wmf, 5) ? WikiSiteToken.Csrf : null,
183185
session = sessionId,
184186
title = title,
185187
clear = clear,

WikiClientLibrary/Sites/WikiSiteToken.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
42
using WikiClientLibrary.Client;
53

64
namespace WikiClientLibrary.Sites
@@ -9,6 +7,10 @@ namespace WikiClientLibrary.Sites
97
/// Represents a token placeholder in the <see cref="MediaWikiFormRequestMessage"/>.
108
/// This enables <see cref="WikiSite"/> to detect bad tokens.
119
/// </summary>
10+
/// <remarks>
11+
/// For backwards-compatibility, please use the most specific token type where possible
12+
/// (e.g., <see cref="Edit"/> or <see cref="Move"/> instead of <see cref="Csrf"/>).
13+
/// </remarks>
1214
public sealed class WikiSiteToken
1315
{
1416

@@ -20,6 +22,9 @@ public sealed class WikiSiteToken
2022

2123
public static WikiSiteToken Patrol = new WikiSiteToken("patrol");
2224

25+
/// <summary>General CSRF token. This token type is not supported prior to MW 1.24.</summary>
26+
public static WikiSiteToken Csrf = new WikiSiteToken("csrf");
27+
2328
public WikiSiteToken(string type)
2429
{
2530
Type = type ?? throw new ArgumentNullException(nameof(type));

0 commit comments

Comments
 (0)