[Libreoffice-commits] core.git: sw/qa sw/source
Szymon Kłos
szymon.klos at collabora.com
Tue Nov 21 08:07:05 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 ++--
sw/source/uibase/wrtsh/wrtsh2.cxx | 2 +-
4 files changed, 8 insertions(+), 6 deletions(-)
New commits:
commit 30af6599d59067a8da6dc4075e80069e80e25f09
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>
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 2765e8f0c5fe..66b4ce67f19c 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, FSysStyle::Detect); \
+ bool bOk = aOriginalURL.setFSysPath(sOriginalFileName, FSysStyle::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 281232ca5bfd..c2dbacad1f55 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -982,7 +982,7 @@ OUString AttributeOutputBase::ConvertURL( const OUString& rUrl, bool bAbsoluteOu
INetURLObject anAbsoluteNew;
if ( anAbsoluteParent.GetNewAbsURL( rUrl, &anAbsoluteNew ) )
- sURL = anAbsoluteNew.GetMainURL( INetURLObject::DecodeMechanism::WithCharset );
+ sURL = anAbsoluteNew.GetMainURL( INetURLObject::DecodeMechanism::NONE );
else
sURL = rUrl;
}
@@ -991,7 +991,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::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism::WithCharset );
+ OUString sRelative = INetURLObject::GetRelURL( sParentPath, sToConvert, INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism::NONE );
if ( !sRelative.isEmpty() )
sURL = sRelative;
}
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index 5076f8604bd9..c40d80c3087d 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -528,7 +528,7 @@ void LoadURL( SwViewShell& rVSh, const OUString& rURL, LoadUrlFlags nFilter,
bCorrectURL &= aURL.insertName( sFileURL );
if( bCorrectURL )
- sFileURL = aURL.GetMainURL( INetURLObject::DecodeMechanism::WithCharset );
+ sFileURL = aURL.getFSysPath( FSysStyle::Detect );
}
// We are doing tiledRendering, let the client handles the URL loading.
More information about the Libreoffice-commits
mailing list