From a81298dc6f3872a015d4a8b0ddbe50849a849de5 Mon Sep 17 00:00:00 2001 From: henrikjust Date: Mon, 25 Jul 2011 08:47:49 +0000 Subject: [PATCH] w2l bugfix: Always encode the characters \, { and } in URLs git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@119 f0f2a975-2e09-46c8-9428-3b39399b9f3c --- .../writer2latex/api/ConverterFactory.java | 4 ++-- .../writer2latex/latex/FieldConverter.java | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/source/java/writer2latex/api/ConverterFactory.java b/source/java/writer2latex/api/ConverterFactory.java index 6db8c60..71cf529 100644 --- a/source/java/writer2latex/api/ConverterFactory.java +++ b/source/java/writer2latex/api/ConverterFactory.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * Version 1.2 (2011-07-22) + * Version 1.2 (2011-07-25) * */ @@ -33,7 +33,7 @@ public class ConverterFactory { // Version information private static final String VERSION = "1.1.8"; - private static final String DATE = "2011-07-22"; + private static final String DATE = "2011-07-25"; /** Return the Writer2LaTeX version in the form * (major version).(minor version).(patch level)
diff --git a/source/java/writer2latex/latex/FieldConverter.java b/source/java/writer2latex/latex/FieldConverter.java index 1741e5c..d7be26e 100644 --- a/source/java/writer2latex/latex/FieldConverter.java +++ b/source/java/writer2latex/latex/FieldConverter.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * Version 1.2 (2011-07-22) + * Version 1.2 (2011-07-25) * */ @@ -845,12 +845,12 @@ public class FieldConverter extends ConverterHelper { if (ofr.getTextContent(node).trim().equals(sHref)) { // The link text equals the url ldp.append("\\url{") - .append(oc.isInFootnote() ? escapeHref(sHref) : sHref) + .append(escapeHref(sHref,oc.isInFootnote())) .append("}"); } else { ldp.append("\\href{") - .append(oc.isInFootnote() ? escapeHref(sHref) : sHref) + .append(escapeHref(sHref,oc.isInFootnote())) .append("}{"); // ignore text style (let hyperref.sty handle the decoration): palette.getInlineCv().traverseInlineText(node,ldp,oc); @@ -939,12 +939,17 @@ public class FieldConverter extends ConverterHelper { return ", "+sName+"="+palette.getI18n().convert(sValue,false,palette.getMainContext().getLang()); } - // For href within footnote, we have to escape the # and % characters - private String escapeHref(String s) { + // For the argument to a href, we have to escape or encode certain characters + private String escapeHref(String s, boolean bInFootnote) { StringBuffer buf = new StringBuffer(); for (int i=0; i