Skip to content

Commit d1a7050

Browse files
anarcatgitster
authored andcommitted
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é <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cb5918a commit d1a7050

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

contrib/mw-to-git/Git/Mediawiki.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package Git::Mediawiki;
22

33
use 5.008;
44
use strict;
5+
use POSIX;
56
use Git;
67

78
BEGIN {
@@ -52,7 +53,7 @@ sub smudge_filename {
5253
$filename =~ s/ /_/g;
5354
# Decode forbidden characters encoded in clean_filename
5455
$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'));
5657
}
5758

5859
sub connect_maybe {

0 commit comments

Comments
 (0)