git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3] remote-mediawiki: limit filenames to legal

From
Antoine Beaupré <anarcat@debian.org>
Date
Oct 29, 2017, 18:15 UTC
Message-ID
<20171029181511.29148-2-anarcat@debian.org>
In-Reply-To
<20171029181511.29148-1-anarcat@debian.org>

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>
---
 contrib/mw-to-git/Git/Mediawiki.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/contrib/mw-to-git/Git/Mediawiki.pm b/contrib/mw-to-git/Git/Mediawiki.pm
index d13c4dfa7..917d9e2d3 100644
--- a/contrib/mw-to-git/Git/Mediawiki.pm
+++ b/contrib/mw-to-git/Git/Mediawiki.pm
@@ -2,6 +2,7 @@ package Git::Mediawiki;
 
 use 5.008;
 use strict;
+use POSIX;
 use Git;
 
 BEGIN {
@@ -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 {
-- 
2.11.0
Previous: Antoine Beaupré
Message 6 of 6 in “remote-mediawiki: limit filenames to legal”
  1. remote-mediawiki: limit filenames to legalAntoine Beaupré, Oct 29, 2017
  2. remote-mediawiki: limit filenames to legalAntoine Beaupré, Oct 29, 2017
  3. Matthieu MoyOct 30, 2017
  4. Antoine BeaupréOct 30, 2017
  5. Antoine Beaupré, Oct 29, 2017
  6. remote-mediawiki: limit filenames to legalAntoine Beaupré, Oct 29, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.