summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2017-08-12 12:34:46 +0200
committerJulien Nabet <serval2412@yahoo.fr>2017-08-18 14:11:31 +0200
commit6abbad3c44809d9f8116992475c5efcaafc23dbf (patch)
tree10705014f01880bb3fbb2a57490664105a85855e
parent0d9db27cb03e393397f292b9e09b4ac515a4b883 (diff)
tdf#109104: respect RFC3986 for newlines in ScEncodeURL
Quotation of RFC3986: A percent-encoded octet is encoded as a character triplet, consisting of the percent character "%" followed by the two hexadecimal digits representing that octet's numeric value So test the length of the return of OString::number and add "0" if needed ScEncodeURL was added with: https://cgit.freedesktop.org/libreoffice/core/commit/?id=25434372bf56e0ebdb7e7d47ab3c14c68211509f Thank you to Bele (the bugtracker reporter) for code pointer! Change-Id: I8df102eb38b31933c6ebb15bb25c125b423f722b Reviewed-on: https://gerrit.libreoffice.org/41086 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> (cherry picked from commit dabba2e3368c2e2ae4ab03ddcfc667e13f89841d) Reviewed-on: https://gerrit.libreoffice.org/41278 Tested-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r--sc/source/core/tool/interpr7.cxx9
1 files changed, 8 insertions, 1 deletions
diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx
index 0d8af3173ed2..738447ea16dd 100644
--- a/sc/source/core/tool/interpr7.cxx
+++ b/sc/source/core/tool/interpr7.cxx
@@ -325,7 +325,14 @@ void ScInterpreter::ScEncodeURL()
else
{
aUrlBuf.append( '%' );
- aUrlBuf.append( OString::number( static_cast<unsigned char>( c ), 16 ).toAsciiUpperCase() );
+ OString convertedChar = OString::number( static_cast<unsigned char>( c ), 16 ).toAsciiUpperCase();
+ // RFC 3986 indicates:
+ // "A percent-encoded octet is encoded as a character triplet,
+ // consisting of the percent character "%" followed by the two hexadecimal digits
+ // representing that octet's numeric value"
+ if (convertedChar.getLength() == 1)
+ aUrlBuf.append("0");
+ aUrlBuf.append(convertedChar);
}
}
PushString( OUString::fromUtf8( aUrlBuf.makeStringAndClear() ) );