Skip to content

Commit

Permalink
Scribunto: Add token param since MW 1.40.0-wmf.5.
Browse files Browse the repository at this point in the history
  • Loading branch information
CXuesong committed Oct 23, 2022
1 parent 8bc63cb commit 6c2e2c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions WikiClientLibrary/Scribunto/ScribuntoConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ internal static async Task<ScribuntoEvaluationResult> InvokeApiAsync(WikiSite si
jresult = await site.InvokeMediaWikiApiAsync(new MediaWikiFormRequestMessage(new
{
action = "scribunto-console",
// Since wikimedia/mediawiki-extensions-Scribunto@0f2585244cbdc22580cc431745328a8f1fb270bd (1.40.0-wmf.5)
token = site.SiteInfo.Version.Above(1, 40, 0, MediaWikiDevChannel.Wmf, 5) ? WikiSiteToken.Csrf : null,
session = sessionId,
title = title,
clear = clear,
Expand Down
9 changes: 7 additions & 2 deletions WikiClientLibrary/Sites/WikiSiteToken.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using WikiClientLibrary.Client;

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

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

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

/// <summary>General CSRF token. This token type is not supported prior to MW 1.24.</summary>
public static WikiSiteToken Csrf = new WikiSiteToken("csrf");

public WikiSiteToken(string type)
{
Type = type ?? throw new ArgumentNullException(nameof(type));
Expand Down

0 comments on commit 6c2e2c0

Please sign in to comment.