From 03264aab68f0763ef6fae9dfb6f0c6524b4ab5d3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Wed, 14 Jan 2009 01:27:01 +0000 Subject: [PATCH] InsetHyperlink.cpp: fix http://bugzilla.lyx.org/show_bug.cgi?id=5686 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28141 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetHyperlink.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/insets/InsetHyperlink.cpp b/src/insets/InsetHyperlink.cpp index 0f89b94f1e..4037c18114 100644 --- a/src/insets/InsetHyperlink.cpp +++ b/src/insets/InsetHyperlink.cpp @@ -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; -- 2.39.2