package libmediawiki-perl tags 578691 + patch thanks Hi,
I prepared a patch (attached) for libmediawiki-perl to handle the login token. I verified that login works for the old and new mediawiki versions (with and without login token) using a very simple Perl script that updates a single page (also attached). Please tell us if (when) we should upload the package (and to where). Regards, Ansgar
Index: debian/control =================================================================== --- debian/control (revision 56937) +++ debian/control (working copy) @@ -1,11 +1,12 @@ Source: libmediawiki-perl Section: perl Priority: optional -Build-Depends: debhelper (>= 5.0.0) +Build-Depends: debhelper (>= 5.0.0), quilt (>= 0.45-1) Build-Depends-Indep: perl (>= 5.8.8-7), libwww-perl, libconfig-inihash-perl, libtest-pod-perl, libtest-pod-coverage-perl Maintainer: Debian Perl Group <pkg-perl-maintain...@lists.alioth.debian.org> Uploaders: Michael Mende <deb...@menole.net>, + Ansgar Burchardt <ans...@43-1.org>, David Paleino <d.pale...@gmail.com>, Damyan Ivanov <d...@debian.org>, Gunnar Wolf <gw...@debian.org> Index: debian/changelog =================================================================== --- debian/changelog (revision 56937) +++ debian/changelog (working copy) @@ -1,3 +1,12 @@ +libmediawiki-perl (1.13-1+lenny1) UNRELEASED; urgency=low + + * Add support for login token. (Closes: #578691) + * Use quilt to manage patches. + * Remove David Paleino from Uploaders (as in 1.13-1.1). + * Add myself to Uploaders. + + -- Ansgar Burchardt <ans...@43-1.org> Mon, 26 Apr 2010 15:00:12 +0900 + libmediawiki-perl (1.13-1) unstable; urgency=low * New upstream release Index: debian/patches/login-token.patch =================================================================== --- debian/patches/login-token.patch (revision 0) +++ debian/patches/login-token.patch (revision 0) @@ -0,0 +1,27 @@ +From: Ansgar Burchardt <ans...@43-1.org> +Date: Mon, 26 Apr 2010 14:58:48 +0900 +Origin: vendor +Bug-Debian: http://bugs.debian.org/578691 +Subject: Support login token + +--- libmediawiki-perl-1.13-1.orig/lib/MediaWiki.pm ++++ libmediawiki-perl-1.13-1/lib/MediaWiki.pm +@@ -207,10 +207,17 @@ + return 1; + } + ++ # get login token ++ my $res = $mw->{ua}->request(GET $mw->{index} . "?title=Special:Userlogin"); ++ return $mw->error(ERR_LOGIN_FAILED) unless $res->is_success; ++ ++ my $token; ++ $token = $1 if $res->content() =~ /input type=['"]hidden['"] name=['"]wpLoginToken['"] value=['"]([a-fA-F0-9]+)['"]/i; ++ + my $res = $mw->{ua}->request( + POST $mw->{index} . "?title=Special:Userlogin&action=submitlogin", + Content_Type => 'application/x-www-form-urlencoded', +- Content => [ ( 'wpName' => $user, 'wpPassword' => $pass, 'wpLoginattempt' => 'Log in' ) ] ++ Content => [ ( 'wpName' => $user, 'wpPassword' => $pass, 'wpLoginattempt' => 'Log in' ), defined $token ? (wpLoginToken => $token) : () ] + ); + if($res->code == 302 || $res->header("Set-Cookie")) + { Index: debian/patches/series =================================================================== --- debian/patches/series (revision 0) +++ debian/patches/series (revision 0) @@ -0,0 +1 @@ +login-token.patch Index: debian/rules =================================================================== --- debian/rules (revision 56937) +++ debian/rules (working copy) @@ -11,6 +11,8 @@ # always return the default without waiting for user input. export PERL_MM_USE_DEFAULT=1 +include /usr/share/quilt/quilt.make + PACKAGE=$(shell dh_listpackages) ifndef PERL @@ -20,7 +22,7 @@ TMP =$(CURDIR)/debian/$(PACKAGE) build: build-stamp -build-stamp: +build-stamp: $(QUILT_STAMPFN) dh_testdir $(PERL) Makefile.PL \ @@ -39,7 +41,7 @@ touch $@ -clean: +clean: unpatch dh_testdir dh_testroot dh_clean build-stamp install-stamp
#! /usr/bin/perl use MediaWiki; my $c = MediaWiki->new; $c->setup({ wiki => { host => "192.168.64.23", path => "mediawiki" }, }); print "login: " . $c->login("user", "password") . "\n"; my $pg = $c->get("Foo", "rw"); $pg->{content} = "Blabla $$"; print "save: " . $pg->save() . "\n"; print "PID was $$\n"; # verify revision history of Foo to see that 'user' was logged in
pgpwXwQrebPlz.pgp
Description: PGP signature