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é <anarcat@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Antoine Beaupré committed
Oct 29, 2017 at 14:15 UTC
d1a7050f93768c10fa8c552ba62c3f86193d34c3
1 file changed
+2
-1
contrib/mw-to-git/Git/Mediawiki.pm
+2
-1
@@ -2,6 +2,7 @@ package Git::Mediawiki;
2
3
use 5.008;
4
use strict;
5
+use POSIX;
6
use Git;
7
8
BEGIN {
@@ -52,7 +53,7 @@ sub smudge_filename {
53
$filename =~ s/ /_/g;
54
# Decode forbidden characters encoded in clean_filename
55
$filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf('%c', hex($1))/ge;
55
- return $filename;
56
+ return substr($filename, 0, NAME_MAX-length('.mw'));
57
}
58
59
sub connect_maybe {