]> git.lyx.org Git - features.git/commitdiff
InsetHyperlink.cpp: fix http://bugzilla.lyx.org/show_bug.cgi?id=5686
authorUwe Stöhr <uwestoehr@web.de>
Wed, 14 Jan 2009 01:27:01 +0000 (01:27 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Wed, 14 Jan 2009 01:27:01 +0000 (01:27 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28141 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetHyperlink.cpp

index 0f89b94f1eddd9d05cd7a4d791cd4ee7a6c27fbe..4037c1811469cb742d392d12f01da076e8d575f1 100644 (file)
@@ -84,6 +84,16 @@ int InsetHyperlink::latex(odocstream & os, OutputParams const & runparams) const
                                url.replace(pos, 1, backslash + chars_url[k]);
                        }
                }
+               // Replace the "\" character with a "/" because "\" is not allowed in
+               // URLs and by \href. Only do this when the following character
+               // is not also a "\", because "\\" is valid code
+               docstring const slash = from_ascii("/");
+               for (size_t i = 0, pos;
+                       (pos = url.find('\\', i)) != string::npos;
+                       i = pos + 2) {
+                       if (url[pos + 1] != '\\')
+                               url.replace(pos, 1, slash);
+               }
 
                // add "http://" when the type is web (type = empty)
                // and no "://" or "run:" is given
@@ -100,7 +110,6 @@ int InsetHyperlink::latex(odocstream & os, OutputParams const & runparams) const
        // The characters in chars_name[] need to be changed to a command when
        // they are in the name field.
        if (!name.empty()) {
-
                // handle the "\" character, but only when the following character
                // is not also a "\", because "\\" is valid code
                docstring const textbackslash = from_ascii("\\textbackslash{}");
@@ -110,6 +119,8 @@ int InsetHyperlink::latex(odocstream & os, OutputParams const & runparams) const
                        if (name[pos + 1] != '\\')
                                name.replace(pos, 1, textbackslash);
                }
+               // The characters in chars_name[] need to be changed to a command when
+               // they are in the name field.
                for (int k = 0; k < 6; k++) {
                        for (size_t i = 0, pos;
                                (pos = name.find(chars_name[k], i)) != string::npos;