git-remote-mediawiki: change separator of some regexps
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>
Célestin Matte committed
Jun 14, 2013 at 15:50 UTC
857f21a3c12667cc1f5b6ebcfff9aa550217e189
1 file changed
+3
-3
contrib/mw-to-git/git-remote-mediawiki.perl
+3
-3
@@ -116,7 +116,7 @@ chomp($dumb_push);
116
$dumb_push = ($dumb_push eq "true");
117
118
my $wiki_name = $url;
119
-$wiki_name =~ s/[^\/]*:\/\///;
119
+$wiki_name =~ s{[^/]*://}{};
120
# If URL is like http://user:password@example.com/, we clearly don't
121
# want the password in $wiki_name. While we're there, also remove user
122
# and '@' sign, to avoid author like MWUser@HTTPUser@host.com
@@ -564,7 +564,7 @@ sub mediawiki_smudge {
564
565
sub mediawiki_clean_filename {
566
my $filename = shift;
567
- $filename =~ s/@{[SLASH_REPLACEMENT]}/\//g;
567
+ $filename =~ s{@{[SLASH_REPLACEMENT]}}{/}g;
568
# [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded.
569
# Do a variant of URL-encoding, i.e. looks like URL-encoding,
570
# but with _ added to prevent MediaWiki from thinking this is
@@ -578,7 +578,7 @@ sub mediawiki_clean_filename {
578
579
sub mediawiki_smudge_filename {
580
my $filename = shift;
581
- $filename =~ s/\//@{[SLASH_REPLACEMENT]}/g;
581
+ $filename =~ s{/}{@{[SLASH_REPLACEMENT]}}g;
582
$filename =~ s/ /_/g;
583
# Decode forbidden characters encoded in mediawiki_clean_filename
584
$filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf("%c", hex($1))/ge;