path: root/contrib/mw-to-git
diff options
authorAntoine Beaupré <>2017-10-29 18:15:11 (GMT)
committerJunio C Hamano <>2017-11-01 04:42:38 (GMT)
commitd1a7050f93768c10fa8c552ba62c3f86193d34c3 (patch)
tree0914eeb0fdd3aed3eecb47370ef51069be8face0 /contrib/mw-to-git
parentcb5918aa0d50f50e83787f65c2ddc3dcb10159fe (diff)
remote-mediawiki: limit filenames to legal
mediawiki pages can have names longer than NAME_MAX (generally 255) characters, which will fail on checkout. we simply strip out extra characters, which may mean one page's content will overwrite another (the last editing winning). ideally, we would do a more clever system to find unique names, but that would be more difficult and error prone for a situation that should rarely happen in the first place. Signed-off-by: Antoine Beaupré <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'contrib/mw-to-git')
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/mw-to-git/Git/ b/contrib/mw-to-git/Git/
index d13c4df..917d9e2 100644
--- a/contrib/mw-to-git/Git/
+++ b/contrib/mw-to-git/Git/
@@ -2,6 +2,7 @@ package Git::Mediawiki;
use 5.008;
use strict;
+use POSIX;
use Git;
@@ -52,7 +53,7 @@ sub smudge_filename {
$filename =~ s/ /_/g;
# Decode forbidden characters encoded in clean_filename
$filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf('%c', hex($1))/ge;
- return $filename;
+ return substr($filename, 0, NAME_MAX-length('.mw'));
sub connect_maybe {