Skip to content

Commit

Permalink
git-remote-mediawiki: change separator of some regexps
Browse files Browse the repository at this point in the history
Use {}{} instead of /// when slashes are used inside the regexp so as not to
escape it.

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Célestin Matte authored and Junio C Hamano committed Jun 14, 2013
1 parent 1149957 commit 857f21a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions contrib/mw-to-git/git-remote-mediawiki.perl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
$dumb_push = ($dumb_push eq "true");

my $wiki_name = $url;
$wiki_name =~ s/[^\/]*:\/\///;
$wiki_name =~ s{[^/]*://}{};
# If URL is like http://user:password@example.com/, we clearly don't
# want the password in $wiki_name. While we're there, also remove user
# and '@' sign, to avoid author like MWUser@HTTPUser@host.com
Expand Down Expand Up @@ -564,7 +564,7 @@ sub mediawiki_smudge {

sub mediawiki_clean_filename {
my $filename = shift;
$filename =~ s/@{[SLASH_REPLACEMENT]}/\//g;
$filename =~ s{@{[SLASH_REPLACEMENT]}}{/}g;
# [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded.
# Do a variant of URL-encoding, i.e. looks like URL-encoding,
# but with _ added to prevent MediaWiki from thinking this is
Expand All @@ -578,7 +578,7 @@ sub mediawiki_clean_filename {

sub mediawiki_smudge_filename {
my $filename = shift;
$filename =~ s/\//@{[SLASH_REPLACEMENT]}/g;
$filename =~ s{/}{@{[SLASH_REPLACEMENT]}}g;
$filename =~ s/ /_/g;
# Decode forbidden characters encoded in mediawiki_clean_filename
$filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf("%c", hex($1))/ge;
Expand Down

0 comments on commit 857f21a

Please sign in to comment.