Skip to content

Commit e379831

Browse files
committed
Merge branch 'mm/mediawiki-encoding-fix'
* mm/mediawiki-encoding-fix: git-remote-mediawiki: fix encoding issue for UTF-8 media files git-remote-mediawiki: allow stop/start-ing the test server
2 parents 59e0821 + 9742fb7 commit e379831

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

contrib/mw-to-git/git-remote-mediawiki.perl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,12 @@ sub download_mw_mediafile {
461461

462462
my $response = $mediawiki->{ua}->get($download_url);
463463
if ($response->code == HTTP_CODE_OK) {
464-
return $response->decoded_content;
464+
# It is tempting to return
465+
# $response->decoded_content({charset => "none"}), but
466+
# when doing so, utf8::downgrade($content) fails with
467+
# "Wide character in subroutine entry".
468+
$response->decode();
469+
return $response->content();
465470
} else {
466471
print {*STDERR} "Error downloading mediafile from :\n";
467472
print {*STDERR} "URL: ${download_url}\n";

contrib/mw-to-git/t/install-wiki.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ usage () {
2020
echo " install | -i : Install a wiki on your computer."
2121
echo " delete | -d : Delete the wiki and all its pages and "
2222
echo " content."
23+
echo " start | -s : Start the previously configured lighttpd daemon"
24+
echo " stop : Stop lighttpd daemon."
2325
}
2426

2527

@@ -33,6 +35,14 @@ case "$1" in
3335
wiki_delete
3436
exit 0
3537
;;
38+
"start" | "-s")
39+
start_lighttpd
40+
exit
41+
;;
42+
"stop")
43+
stop_lighttpd
44+
exit
45+
;;
3646
"--help" | "-h")
3747
usage
3848
exit 0

contrib/mw-to-git/t/t9363-mw-to-git-export-import.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ test_expect_success 'git clone works on previously created wiki with media files
5858
test_cmp mw_dir_clone/Foo.txt mw_dir/Foo.txt
5959
'
6060

61+
test_expect_success 'git push can upload media (File:) files containing valid UTF-8' '
62+
wiki_reset &&
63+
git clone mediawiki::'"$WIKI_URL"' mw_dir &&
64+
(
65+
cd mw_dir &&
66+
"$PERL_PATH" -e "print STDOUT \"UTF-8 content: éèàéê€.\";" >Bar.txt &&
67+
git add Bar.txt &&
68+
git commit -m "add a text file with UTF-8 content" &&
69+
git push
70+
)
71+
'
72+
73+
test_expect_success 'git clone works on previously created wiki with media files containing valid UTF-8' '
74+
test_when_finished "rm -rf mw_dir mw_dir_clone" &&
75+
git clone -c remote.origin.mediaimport=true \
76+
mediawiki::'"$WIKI_URL"' mw_dir_clone &&
77+
test_cmp mw_dir_clone/Bar.txt mw_dir/Bar.txt
78+
'
79+
6180
test_expect_success 'git push & pull work with locally renamed media files' '
6281
wiki_reset &&
6382
git clone mediawiki::'"$WIKI_URL"' mw_dir &&

contrib/mw-to-git/t/test-gitmw-lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ start_lighttpd () {
289289
# Kill daemon lighttpd and removes files and folders associated.
290290
stop_lighttpd () {
291291
test -f "$WEB_TMP/pid" && kill $(cat "$WEB_TMP/pid")
292-
rm -rf "$WEB"
293292
}
294293

295294
# Create the SQLite database of the MediaWiki. If the database file already
@@ -415,6 +414,7 @@ wiki_reset () {
415414
wiki_delete () {
416415
if test $LIGHTTPD = "true"; then
417416
stop_lighttpd
417+
rm -fr "$WEB"
418418
else
419419
# Delete the wiki's directory.
420420
rm -rf "$WIKI_DIR_INST/$WIKI_DIR_NAME" ||

0 commit comments

Comments
 (0)