This patch is from bugzilla: http://bugzilla.lyx.org/show_bug.cgi?id=2937
(with slightly modified comment)

I will put it in later today if nobody objects.


Georg
Index: src/support/filename.C
===================================================================
--- src/support/filename.C	(Revision 17376)
+++ src/support/filename.C	(Arbeitskopie)
@@ -167,14 +167,17 @@ string const DocFileName::mangledFilenam
 	string mname = os::internal_path(name_);
 	// Remove the extension.
 	mname = changeExtension(name_, string());
-	// Replace '/' in the file name with '_'
-	mname = subst(mname, "/", "_");
-	// Replace '.' in the file name with '_'
-	mname = subst(mname, ".", "_");
-	// Replace ' ' in the file name with '_'
-	mname = subst(mname, " ", "_");
-	// Replace ':' in the file name with '_'
-	mname = subst(mname, ":", "_");
+	// The mangled name must be a valid LaTeX name.
+	// The list of characters to keep is probably over-restrictive,
+	// but it is not really a problem.
+	// Apart from non-ASCII charcaters, at least the following characters
+	// are forbidden: '/', '.', ' ', ':'
+	static string const keep = "abcdefghijklmnopqrstuvwxyz"
+	                           "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+	                           "+,-0123456789;<=>?";
+	string::size_type pos = 0;
+	while ((pos = mname.find_first_not_of(keep, pos)) != string::npos)
+		mname[pos++] = '_';
 	// Add the extension back on
 	mname = changeExtension(mname, getExtension(name_));
 

Reply via email to