Skip to content

Commit

Permalink
Base64Decoder drops 0x0d characters on windows
Browse files Browse the repository at this point in the history
SF 605 Base64Decoder drops 0x0d characters on windows
  • Loading branch information
aleks-f committed Dec 21, 2012
1 parent 9a67596 commit 99bd020
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions Foundation/src/Base32Decoder.cpp
Expand Up @@ -171,6 +171,7 @@ Base32DecoderBuf* Base32DecoderIOS::rdbuf()

Base32Decoder::Base32Decoder(std::istream& istr): Base32DecoderIOS(istr), std::istream(&_buf)
{
unsetf(std::ios_base::skipws);
}


Expand Down
1 change: 1 addition & 0 deletions Foundation/src/Base64Decoder.cpp
Expand Up @@ -147,6 +147,7 @@ Base64DecoderBuf* Base64DecoderIOS::rdbuf()

Base64Decoder::Base64Decoder(std::istream& istr): Base64DecoderIOS(istr), std::istream(&_buf)
{
unsetf(std::ios_base::skipws);
}


Expand Down
16 changes: 16 additions & 0 deletions Foundation/testsuite/src/Base32Test.cpp
Expand Up @@ -37,6 +37,8 @@
#include "Poco/Base32Decoder.h"
#include "Poco/Exception.h"
#include <sstream>
#include <iterator>
#include <algorithm>


using Poco::Base32Encoder;
Expand Down Expand Up @@ -182,6 +184,19 @@ void Base32Test::testEncodeDecode()
}


void Base32Test::testDecodeCR()
{
std::istringstream input("BU======");
Poco::Base32Decoder decoder(input);
std::vector<Poco::UInt8> result;
typedef std::istream_iterator<Poco::UInt8> istream_iterator_type;
istream_iterator_type eos;
std::copy(istream_iterator_type(decoder), eos, std::back_inserter(result));
assert(1 == result.size());
assert(0x0d == result[0]);
}


void Base32Test::setUp()
{
}
Expand All @@ -199,6 +214,7 @@ CppUnit::Test* Base32Test::suite()
CppUnit_addTest(pSuite, Base32Test, testEncoder);
CppUnit_addTest(pSuite, Base32Test, testDecoder);
CppUnit_addTest(pSuite, Base32Test, testEncodeDecode);
CppUnit_addTest(pSuite, Base32Test, testDecodeCR);

return pSuite;
}
1 change: 1 addition & 0 deletions Foundation/testsuite/src/Base32Test.h
Expand Up @@ -49,6 +49,7 @@ class Base32Test: public CppUnit::TestCase
void testEncoder();
void testDecoder();
void testEncodeDecode();
void testDecodeCR();

void setUp();
void tearDown();
Expand Down
16 changes: 16 additions & 0 deletions Foundation/testsuite/src/Base64Test.cpp
Expand Up @@ -37,6 +37,8 @@
#include "Poco/Base64Decoder.h"
#include "Poco/Exception.h"
#include <sstream>
#include <iterator>
#include <algorithm>


using Poco::Base64Encoder;
Expand Down Expand Up @@ -177,6 +179,19 @@ void Base64Test::testEncodeDecode()
}


void Base64Test::testDecodeCR()
{
std::istringstream input("DQ==");
Poco::Base64Decoder decoder(input);
std::vector<Poco::UInt8> result;
typedef std::istream_iterator<Poco::UInt8> istream_iterator_type;
istream_iterator_type eos;
std::copy(istream_iterator_type(decoder), eos, std::back_inserter(result));
assert(1 == result.size());
assert(0x0d == result[0]);
}


void Base64Test::setUp()
{
}
Expand All @@ -194,6 +209,7 @@ CppUnit::Test* Base64Test::suite()
CppUnit_addTest(pSuite, Base64Test, testEncoder);
CppUnit_addTest(pSuite, Base64Test, testDecoder);
CppUnit_addTest(pSuite, Base64Test, testEncodeDecode);
CppUnit_addTest(pSuite, Base64Test, testDecodeCR);

return pSuite;
}
1 change: 1 addition & 0 deletions Foundation/testsuite/src/Base64Test.h
Expand Up @@ -49,6 +49,7 @@ class Base64Test: public CppUnit::TestCase
void testEncoder();
void testDecoder();
void testEncodeDecode();
void testDecodeCR();

void setUp();
void tearDown();
Expand Down

0 comments on commit 99bd020

Please sign in to comment.