Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#605 Base64Decoder drops 0x0d characters on windows

Feature_Request
open
nobody
None
1
2012-12-21
2012-12-19
Aviad Rozenhek
No
Poco::Base64Decoder doesn't work properly on windows systems. the code below shows a unit test that fails on windows with poco 1.44 [didn't test on other releases].

the proposed fix is adding a call to this->unsetf(std::ios_base::skipws); in the Base64Decoder constructor

   #include <Poco/Base64Decoder.h>
   #include <algorithm>
   #include <iterator>
   #include <stdint.h>
   #include <gtest/gtest.h>
   TEST(poco_base64decode_tests, decode_0x0d_test)
   {
       std::istringstream input("DQ==");
       Poco::Base64Decoder decoder(input); // the fix is adding the following line: decoder.unsetf(std::ios_base::skipws);
       std::vector<uint8_t> result;
       typedef std::istream_iterator<uint8_t> istream_iterator_type;
       istream_iterator_type eos;
       std::copy(istream_iterator_type(decoder), eos, std::back_inserter(result));
       ASSERT_EQ(1, result.size()); // fails, because result.size() is 0
       ASSERT_EQ(0x0d, result[0]); // fails
   }

Discussion

<< < 1 2 (Page 2 of 2)
  • Alex Fabijanic
    Alex Fabijanic
    2012-12-20

    With poco streams being an extension of the standard IO stream inheritance tree, this is fundamentally the standard problem. We are, however, "guilty by association" and we should know better (as Meyers said, "interfaces should be easy to use correctly and hard to use incorrectly"). So, I would still be inclined to consistently offer some options at construction, at least for streams dealing primarily with binary data. I will revert this change in github, not include it in 1.5.1, create a separate github branch and we can see where to take it from there.

     
  • Alex Fabijanic
    Alex Fabijanic
    2012-12-21

    • status: accepted --> open
    • milestone: Platform_Specific --> Not_a_Bug
     
  • Alex Fabijanic
    Alex Fabijanic
    2012-12-21

    • milestone: Not_a_Bug --> Feature_Request
     
<< < 1 2 (Page 2 of 2)