You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ka...@apache.org on 2018/02/20 21:13:16 UTC
mesos git commit: Allowed base64-decoding with whitespaces.
Repository: mesos
Updated Branches:
refs/heads/master 75dd71886 -> 661ac5beb
Allowed base64-decoding with whitespaces.
Most base64 decoders do not fail on encountering whitespace characters
as several encoders embed newlines to enforce line-width in encoded
data.
Review: https://reviews.apache.org/r/65696
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/661ac5be
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/661ac5be
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/661ac5be
Branch: refs/heads/master
Commit: 661ac5bebbdb6623e6e00f65a3d7e16492f6d9ae
Parents: 75dd718
Author: Kapil Arya <ka...@mesosphere.io>
Authored: Fri Feb 16 19:25:18 2018 -0500
Committer: Kapil Arya <ka...@mesosphere.io>
Committed: Tue Feb 20 16:12:21 2018 -0500
----------------------------------------------------------------------
3rdparty/stout/include/stout/base64.hpp | 11 +++++++++++
3rdparty/stout/tests/base64_tests.cpp | 11 ++++++++---
2 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/661ac5be/3rdparty/stout/include/stout/base64.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/base64.hpp b/3rdparty/stout/include/stout/base64.hpp
index eabc9b0..9530c68 100644
--- a/3rdparty/stout/include/stout/base64.hpp
+++ b/3rdparty/stout/include/stout/base64.hpp
@@ -107,6 +107,17 @@ inline Try<std::string> decode(const std::string& s, const std::string& chars)
break; // Reached the padding.
}
+ // The base RFC (https://tools.ietf.org/html/rfc4648#section-3.3) explicitly
+ // asks to reject non-alphabet characters including newlines and
+ // whitespaces. However, other specifications like MIME simply ignore
+ // characters outside the base alphabet ("be liberal in what you accept").
+ // Further, most implementation ignore whiltespace characters when
+ // processing encoded data. This allows tools to delimit encoded with
+ // newlines or other whitespace characters for better readability, etc.
+ if (isspace(c)) {
+ continue;
+ }
+
if (!isBase64(c)) {
return Error("Invalid character '" + stringify(c) + "'");
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/661ac5be/3rdparty/stout/tests/base64_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/base64_tests.cpp b/3rdparty/stout/tests/base64_tests.cpp
index a6837c8..32d32d0 100644
--- a/3rdparty/stout/tests/base64_tests.cpp
+++ b/3rdparty/stout/tests/base64_tests.cpp
@@ -29,9 +29,14 @@ TEST(Base64Test, Decode)
EXPECT_SOME_EQ("user:password", base64::decode("dXNlcjpwYXNzd29yZA="));
EXPECT_SOME_EQ("user:password", base64::decode("dXNlcjpwYXNzd29yZA"));
- // Whitespace is not allowed.
- EXPECT_ERROR(base64::decode("d XNlcjpwYXNzd29yZA=="));
- EXPECT_ERROR(base64::decode("d\r\nXNlcjpwYXNzd29yZA=="));
+ // Whitespaces are allowed.
+ EXPECT_SOME_EQ("user:password", base64::decode("d XNlcjpwYXNzd29yZA=="));
+ EXPECT_SOME_EQ("user:password", base64::decode("d\tXNlcjpwYXNzd29yZA=="));
+ EXPECT_SOME_EQ("user:password", base64::decode("d\nXNlcjpwYXNzd29yZA=="));
+ EXPECT_SOME_EQ("user:password", base64::decode("d\vXNlcjpwYXNzd29yZA=="));
+ EXPECT_SOME_EQ("user:password", base64::decode("d\fXNlcjpwYXNzd29yZA=="));
+ EXPECT_SOME_EQ("user:password", base64::decode("d\rXNlcjpwYXNzd29yZA=="));
+ EXPECT_SOME_EQ("user:password", base64::decode("d\r\nXNlcjpwYXNzd29yZA=="));
// Invalid characters.
EXPECT_ERROR(base64::decode("abc("));