]> git.lyx.org Git - features.git/commitdiff
Fix bugs 3240 and 3241
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 18 Feb 2007 18:29:25 +0000 (18:29 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 18 Feb 2007 18:29:25 +0000 (18:29 +0000)
* src/insets/ExternalSupport.C
(doSubstitution): redo the substitution with use_latex_path == false
for the filename argument of $$Contents, since the original
substitution might have been done with use_latex_path == true, and
that can lead to escaped filenames that are only valid for TeX.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17242 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/ExternalSupport.C

index 3b7d722ed4e2ab072334bd1a15ab17fffb866683..28ca719992d080d41e95aaa0a665ef8cae8f0289 100644 (file)
@@ -167,10 +167,15 @@ string const doSubstitution(InsetExternalParams const & params,
 
        // Handle the $$Contents(filename) syntax
        if (support::contains(result, "$$Contents(\"")) {
-
-               string::size_type const pos = result.find("$$Contents(\"");
-               string::size_type const end = result.find("\")", pos);
-               string const file = result.substr(pos + 12, end - (pos + 12));
+               // Since use_latex_path may be true we must extract the file
+               // name from s instead of result and do the substitutions
+               // again, this time with use_latex_path false.
+               string::size_type const spos = s.find("$$Contents(\"");
+               string::size_type const send = s.find("\")", spos);
+               string const file_template = s.substr(spos + 12, send - (spos + 12));
+               string const file = doSubstitution(params, buffer,
+                                                  file_template, false,
+                                                  external_in_tmpdir, what);
                string contents;
 
                FileName const absfile(
@@ -178,9 +183,9 @@ string const doSubstitution(InsetExternalParams const & params,
                if (support::isFileReadable(absfile))
                        contents = support::getFileContents(absfile);
 
-               result = support::subst(result,
-                                       ("$$Contents(\"" + file + "\")").c_str(),
-                                       contents);
+               string::size_type const pos = result.find("$$Contents(\"");
+               string::size_type const end = result.find("\")", pos);
+               result.replace(pos, end + 2, contents);
        }
 
        return result;