See http://bugzilla.lyx.org/show_bug.cgi?id=3305. This patch fixes two
problems:

- char() == 0, so a string with an embedded 0 character could be created.
This is not what was intended.

- fs::exists was called for a filename that was not checked with fs::native,
so an excpetion could be thrown.

This is going in now.

BTW I don't like this test for max path length:


        if (token.length() > 255) {
                // string too long. Cut off.
                int r = token.length() - 250;
                string ntoken = token.substr(r, token.length());
                token = ntoken;
        }

Nobody knows where the 255 comes from. I believe that this test is no longer
needed (the fs::native check should catch these cases, can anybody confirm
this?), but if it is, then something like this should be used:


        int const max_windows_path_length = 255;
        if (token.length() > max_windows_path_length ) {
                // string too long. Cut off.
                int r = token.length() - max_windows_path_length + 5;
                token = token.substr(r, token.length());
        }


Georg
Index: src/LaTeX.C
===================================================================
--- src/LaTeX.C	(Revision 17451)
+++ src/LaTeX.C	(Arbeitskopie)
@@ -833,13 +833,12 @@ bool handleFoundFile(string const & ff, 
 		if (exists)
 			// everything o.k.
 			break;
-		else {
+		else if (contains(foundfile, '"')) {
 			// files with spaces are often enclosed in quotation
-			// marks; those have to be removed
-			string unquoted = subst(foundfile, '"', char());
+			// marks; remove those and try again
+			string unquoted = subst(foundfile, "\"", "");
 			absname = makeAbsPath(unquoted);
-			if (fs::exists(absname.toFilesystemEncoding()))
-				break;
+		} else {
 			// strip off part after last space and try again
 			string strippedfile;
 			string const stripoff =

Reply via email to