Skip to content

Poco::JSON::Stringifier::stringify bad behaviour #482

@miguelangelorenes

Description

@miguelangelorenes

Testing this code
std::string str = "HTTP/1.1 200 OK\r\nDate: Thu, 03 Jul 2014 12:57:06 GMT\r\nConnection: Close";
Poco::JSON::Object obj;
obj.set("payload", str);
std::ostringstream oss;
Poco::JSON::Stringifier::stringify( obj, oss );
std::cout << "Payload before Stringify: " << str << std::endl;
std::cout << "Payload after Stringify: " << oss.str() << std::endl;

I am getting the next output:
Payload before Stringify: HTTP/1.1 200 OK
Date: Thu, 03 Jul 2014 12:57:06 GMT
Connection: Close
\ayload after Stringify: {"payload":"HTTP/1.1 200 OK
\ate: Thu, 03 Jul 2014 12:57:06 GMT
Connection: Close"}

With poco master version, previous #176 fix, this code worked fine.

Taking a look on Poco::JSON::Stringifier::formatString code, it looks like:
if (*it <= 0x1F || *it == '"' || *it == '' || *it == '/')
{
out << '';
}
out << *it;
is not working ok because is transforming, for example, "\n" to "\n".

As additional information, I changed new "formatString" code the previous implementation and it worked fine.

The same problem happens on Poco-develop version.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions