InsetHyperlink.cpp: - fix #5908 for branch

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29380 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2009-04-22 21:32:21 +00:00
parent 1a05b88ca4
commit 93b6399c77
2 changed files with 14 additions and 2 deletions

View File

@ -70,6 +70,7 @@ int InsetHyperlink::latex(odocstream & os, OutputParams const & runparams) const
docstring name = getParam("name");
static docstring const backslash = from_ascii("\\");
static docstring const braces = from_ascii("{}");
static char_type const chars_url[2] = {'%', '#'};
static char_type const chars_name[6] = {
'&', '_', '$', '%', '#', '^'};
@ -79,8 +80,6 @@ int InsetHyperlink::latex(odocstream & os, OutputParams const & runparams) const
if (name.empty())
name = url;
// The characters in chars_url[] need to be changed to a command when
// they are in the url field.
if (!url.empty()) {
// Replace the "\" character by its ASCII code according to the URL specifications
// because "\" is not allowed in URLs and by \href. Only do this when the
@ -92,6 +91,16 @@ int InsetHyperlink::latex(odocstream & os, OutputParams const & runparams) const
url.replace(pos, 1, from_ascii("%5C"));
}
// The characters in chars_url[] need to be escaped in the url
// field because otherwise LaTeX will fail when the hyperlink is
// within an argument of another command, e.g. in a \footnote. It
// is important that they are escaped as "\#" and not as "\#{}".
for (int k = 0; k < 2; k++)
for (size_t i = 0, pos;
(pos = url.find(chars_url[k], i)) != string::npos;
i = pos + 2)
url.replace(pos, 1, backslash + chars_url[k]);
// add "http://" when the type is web (type = empty)
// and no "://" or "run:" is given
docstring type = getParam("type");

View File

@ -120,6 +120,9 @@ What's new
- Fix reading of document when a customizable inset name contains a
space.
- Fix bug when using the characters # and % in hyperlinks that are e.g.
in footnotes (bug 5908).
- Fix LaTeX export of an isolated Japanese character when using
ISO-2022-JP encoding (bug 5802).