Kaydet (Commit) dabba2e3 authored tarafından Julien Nabet's avatar Julien Nabet Kaydeden (comit) Eike Rathke

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/41086Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
üst 08566ea5
...@@ -325,7 +325,14 @@ void ScInterpreter::ScEncodeURL() ...@@ -325,7 +325,14 @@ void ScInterpreter::ScEncodeURL()
else else
{ {
aUrlBuf.append( '%' ); 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() ) ); PushString( OUString::fromUtf8( aUrlBuf.makeStringAndClear() ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment