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:10:29 +0200
commitfdaee404f3216441d6b78636c0defae580f26034 (patch)
treee5c7a317a4839fc7da8f6c98931739c400c8c678
parent5dbbc6635d339aeca4efa61b3d6e749f264667e1 (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
-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 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() ) );