]> git.lyx.org Git - lyx.git/blobdiff - src/insets/ExternalSupport.cpp
Fix for bug 4135
[lyx.git] / src / insets / ExternalSupport.cpp
index ecfd61797c6ce4e45af0e386e6c728f388940078..2210a1bc721a8b078bd2688939e6bfe732a70b7d 100644 (file)
 #include "Buffer.h"
 #include "Converter.h"
 #include "debug.h"
+#include "gettext.h"
 #include "ErrorList.h"
 #include "Exporter.h"
 #include "Format.h"
 #include "Mover.h"
 
+#include "frontends/alert.h"
+
 #include "support/filetools.h"
 #include "support/Forkedcall.h"
 #include "support/lstrings.h"
@@ -34,6 +37,8 @@
 
 #include <boost/filesystem/operations.hpp>
 
+#include <algorithm>
+
 using std::endl;
 using std::string;
 using std::vector;
@@ -44,6 +49,7 @@ using boost::filesystem::is_directory;
 namespace lyx {
 
 using support::FileName;
+using support::isValidLaTeXFilename;
 
 namespace external {
 
@@ -368,11 +374,22 @@ int writeExternal(InsetExternalParams const & params,
        bool const use_latex_path = format == "LaTeX";
        string str = doSubstitution(params, buffer, cit->second.product,
                                    use_latex_path, external_in_tmpdir);
+
+       string const absname = support::makeAbsPath(
+               params.filename.outputFilename(buffer.filePath()), buffer.filePath()).absFilename();
+
+       if (!external_in_tmpdir && !isValidLaTeXFilename(absname)) {
+               lyx::frontend::Alert::warning(_("Invalid filename"),
+                                             _("The following filename is likely to cause trouble "
+                                               "when running the exported file through LaTeX: ") +
+                                             from_utf8(absname));
+       }
+
        str = substituteCommands(params, str, format);
        str = substituteOptions(params, str, format);
        // FIXME UNICODE
        os << from_utf8(str);
-       return int(lyx::count(str.begin(), str.end(),'\n'));
+       return int(std::count(str.begin(), str.end(),'\n'));
 }
 
 namespace {