[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source
Szymon Kłos
szymon.klos at collabora.com
Tue Nov 21 21:40:47 UTC 2017
sw/qa/extras/ooxmlexport/data/absolute-link.docx |binary
sw/qa/extras/ooxmlexport/ooxmllinks.cxx | 8 +++++---
sw/source/filter/ww8/wrtw8nds.cxx | 4 ++--
3 files changed, 7 insertions(+), 5 deletions(-)
New commits:
commit 84dda56fe8c9b8999fda61d95b0615be57d6e97f
Author: Szymon Kłos <szymon.klos at collabora.com>
Date: Mon Nov 20 22:40:21 2017 +0100
tdf#86087 don't decode links
Example of link causing problems: "file:///foo#bar"
Change-Id: Ifb781c27c3b9726ba262f10cf07c13cfd889dcd3
Reviewed-on: https://gerrit.libreoffice.org/45010
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>
Reviewed-on: https://gerrit.libreoffice.org/45051
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/sw/qa/extras/ooxmlexport/data/absolute-link.docx b/sw/qa/extras/ooxmlexport/data/absolute-link.docx
index 34480d0a2b94..db36a6f32a87 100755
Binary files a/sw/qa/extras/ooxmlexport/data/absolute-link.docx and b/sw/qa/extras/ooxmlexport/data/absolute-link.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
index 5d1c8f6a2d56..b6a1f77061fd 100755
--- a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx
@@ -39,7 +39,8 @@ protected: \
/* Get original link */ \
OUString sOriginalFileName = getProperty<OUString>(xText, "HyperLinkURL"); \
INetURLObject aOriginalURL; \
- aOriginalURL.setFSysPath(sOriginalFileName, INetURLObject::FSYS_DETECT); \
+ bool bOk = aOriginalURL.setFSysPath(sOriginalFileName, INetURLObject::FSYS_DETECT); \
+ if(!bOk) aOriginalURL = INetURLObject(sOriginalFileName); \
OUString sFileName = aOriginalURL.GetName().isEmpty() ? sOriginalFileName : aOriginalURL.GetName(); \
\
/* Get temp path */ \
@@ -139,7 +140,8 @@ DECLARE_LINKS_IMPORT_TEST(testAbsoluteToAbsoluteImport, "absolute-link.docx", US
{
uno::Reference<text::XTextRange> xParagraph = getParagraph(1);
uno::Reference<text::XTextRange> xText = getRun(xParagraph, 1);
- CPPUNIT_ASSERT_EQUAL(OUString("file:///B:\\Users\\user\\Desktop\\test.docx"), getProperty<OUString>(xText, "HyperLinkURL"));
+ // # should be encoded
+ CPPUNIT_ASSERT_EQUAL(OUString("file:///B:/Users/user/Desktop/a%23b/test.docx"), getProperty<OUString>(xText, "HyperLinkURL"));
}
DECLARE_LINKS_IMPORT_TEST(testAbsoluteToRelativeImport, "absolute-link.docx", USE_RELATIVE)
@@ -147,7 +149,7 @@ DECLARE_LINKS_IMPORT_TEST(testAbsoluteToRelativeImport, "absolute-link.docx", US
uno::Reference<text::XTextRange> xParagraph = getParagraph(1);
uno::Reference<text::XTextRange> xText = getRun(xParagraph, 1);
// when target file (B:\\...) & document with link (temp dir) are placed on different partitions, absolute path will be loaded
- CPPUNIT_ASSERT_EQUAL(OUString("file:///B:\\Users\\user\\Desktop\\test.docx"), getProperty<OUString>(xText, "HyperLinkURL"));
+ CPPUNIT_ASSERT_EQUAL(OUString("file:///B:/Users/user/Desktop/a%23b/test.docx"), getProperty<OUString>(xText, "HyperLinkURL"));
}
/* EXPORT */
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index bc98076f174c..467355777f29 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -947,7 +947,7 @@ OUString AttributeOutputBase::ConvertURL( const OUString& rUrl, bool bAbsoluteOu
INetURLObject anAbsoluteNew;
if ( anAbsoluteParent.GetNewAbsURL( rUrl, &anAbsoluteNew ) )
- sURL = anAbsoluteNew.GetMainURL( INetURLObject::DECODE_WITH_CHARSET );
+ sURL = anAbsoluteNew.GetMainURL( INetURLObject::NO_DECODE );
else
sURL = rUrl;
}
@@ -956,7 +956,7 @@ OUString AttributeOutputBase::ConvertURL( const OUString& rUrl, bool bAbsoluteOu
OUString sToConvert = rUrl.replaceAll( "\\", "/" );
INetURLObject aURL( sToConvert );
sToConvert = INetURLObject::GetScheme( aURL.GetProtocol() ) + aURL.GetURLPath();
- OUString sRelative = INetURLObject::GetRelURL( sParentPath, sToConvert, INetURLObject::WAS_ENCODED, INetURLObject::DECODE_WITH_CHARSET );
+ OUString sRelative = INetURLObject::GetRelURL( sParentPath, sToConvert, INetURLObject::WAS_ENCODED, INetURLObject::NO_DECODE );
if ( !sRelative.isEmpty() )
sURL = sRelative;
}
More information about the Libreoffice-commits
mailing list