summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-11-20 22:40:21 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-11-21 09:06:40 +0100
commit30af6599d59067a8da6dc4075e80069e80e25f09 (patch)
tree3c1e99f2179332e3f860fe154f5c638399d63231
parentbb11e1283e3d49ec1bfe14c4271edbd49af3e3c1 (diff)
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@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rwxr-xr-xsw/qa/extras/ooxmlexport/data/absolute-link.docxbin13233 -> 10533 bytes
-rwxr-xr-xsw/qa/extras/ooxmlexport/ooxmllinks.cxx8
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx4
-rw-r--r--sw/source/uibase/wrtsh/wrtsh2.cxx2
4 files changed, 8 insertions, 6 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/absolute-link.docx b/sw/qa/extras/ooxmlexport/data/absolute-link.docx
index 34480d0a2b94..db36a6f32a87 100755
--- a/sw/qa/extras/ooxmlexport/data/absolute-link.docx
+++ b/sw/qa/extras/ooxmlexport/data/absolute-link.docx
Binary files 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.