From fdaee404f3216441d6b78636c0defae580f26034 Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Sat, 12 Aug 2017 12:34:46 +0200 Subject: 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 Reviewed-by: Eike Rathke (cherry picked from commit dabba2e3368c2e2ae4ab03ddcfc667e13f89841d) Reviewed-on: https://gerrit.libreoffice.org/41279 --- sc/source/core/tool/interpr7.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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( c ), 16 ).toAsciiUpperCase() ); + OString convertedChar = OString::number( static_cast( 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() ) ); -- cgit v1.2.3