Am 18.01.2011 um 07:31 schrieb Stephan Witt:

> Am 18.01.2011 um 07:03 schrieb Vincent van Ravesteijn:
> 
>> Because if the variable is not a variable, it might just be a filename 
>> containing a $.
> 
> But the function replaceEnvironmentPath() don't know if the $ is in the 
> filename
> or is a environment variable.
> 
> If the filename e. g. contains $TEMP this would happily be replaced. And I can
> call it a bug too, since the syntax for environment variables on windows is 
> %TEMP%.
> Another story I have to tell: if you are using a $ in filename and save this
> file in an unix based source code system you are in trouble too.
> There are some things better to avoid.
> 
> But ok, one always should try harder... I said it already: if the real 
> filename
> contains a $ and we want to support that we should do it right. Then the call
> to replaceEnvironmentPath() is wrong or it should be possible to escape the $ 
> somehow.

To illustrate my proposal to avoid wrong replaceEnvironmentPath() calls
I attach an example patch for GuiView::openDocument()...

A file name explicitly selected via file-open dialog doesn't need a 
fileSearch() post processing.

I claim this is a better fix for ticket http://www.lyx.org/trac/ticket/4177
Other locations may affected to.

Stephan

Index: src/frontends/qt4/GuiView.cpp
===================================================================
--- src/frontends/qt4/GuiView.cpp       (Revision 37244)
+++ src/frontends/qt4/GuiView.cpp       (Arbeitskopie)
@@ -1950,13 +1950,14 @@
                        message(_("Canceled."));
                        return;
                }
-       } else
-               filename = fname;
+       } else {
+               // get absolute path of file and add ".lyx" to the filename if
+               // necessary.
+               filename = fileSearch(string(), fname, "lyx", 
support::may_not_exist).absFileName();
+       }
 
-       // get absolute path of file and add ".lyx" to the filename if
-       // necessary.
-       FileName const fullname =
-                       fileSearch(string(), filename, "lyx", 
support::may_not_exist);
+       FileName const fullname = FileName(filename);
+
        if (!fullname.empty())
                filename = fullname.absFileName();
 

Reply via email to