diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2017-08-12 12:34:46 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2017-08-21 09:00:36 +0200 |
commit | dfc0f39d32665051d9010ff25b686e88215925b0 (patch) | |
tree | a8cb07d12d10d8e22e985018de815948690692cb /sc | |
parent | f8440ce333c5055ddac3ae3dffb2a5b107c4ead1 (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/41279
(cherry picked from commit fdaee404f3216441d6b78636c0defae580f26034)
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/tool/interpr7.cxx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx index b226717c2935..48a34b3ece36 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() ) ); |