From d0b6a88f9c2eeea46ea4a8d2fd769b45d138185d Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 25 Nov 2015 23:08:24 +0900 Subject: [PATCH] Base32 decode lowercased characters as well --- src/base32.h | 2 ++ test/Base32Test.cc | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/base32.h b/src/base32.h index a93f9180..203bb8b9 100644 --- a/src/base32.h +++ b/src/base32.h @@ -64,6 +64,8 @@ std::string decode(InputIterator first, InputIterator last) unsigned char value; if('A' <= ch && ch <= 'Z') { value = ch-'A'; + } else if('a' <= ch && ch <= 'z') { + value = ch-'a'; } else if('2' <= ch && ch <= '7') { value = ch-'2'+26; } else if(ch == '=') { diff --git a/test/Base32Test.cc b/test/Base32Test.cc index 03d52e8d..aca15b53 100644 --- a/test/Base32Test.cc +++ b/test/Base32Test.cc @@ -48,6 +48,9 @@ void Base32Test::testDecode() s = "GEZDGNBV"; CPPUNIT_ASSERT_EQUAL(std::string("12345"), base32::decode(s.begin(), s.end())); + s = "gezdgnbv"; + CPPUNIT_ASSERT_EQUAL(std::string("12345"), + base32::decode(s.begin(), s.end())); } } // namespace aria2