{"action":"created","issue":{"url":"https://api.github.com/repos/willdurand/EmailReplyParser/issues/34","labels_url":"https://api.github.com/repos/willdurand/EmailReplyParser/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/willdurand/EmailReplyParser/issues/34/comments","events_url":"https://api.github.com/repos/willdurand/EmailReplyParser/issues/34/events","html_url":"https://github.com/willdurand/EmailReplyParser/issues/34","id":89246561,"number":34,"title":"$fragment->getContent() removes newlines returning a modified fragment from the original text.","user":{"login":"cristobal-wetzig","id":478079,"avatar_url":"https://avatars.githubusercontent.com/u/478079?v=3","gravatar_id":"","url":"https://api.github.com/users/cristobal-wetzig","html_url":"https://github.com/cristobal-wetzig","followers_url":"https://api.github.com/users/cristobal-wetzig/followers","following_url":"https://api.github.com/users/cristobal-wetzig/following{/other_user}","gists_url":"https://api.github.com/users/cristobal-wetzig/gists{/gist_id}","starred_url":"https://api.github.com/users/cristobal-wetzig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cristobal-wetzig/subscriptions","organizations_url":"https://api.github.com/users/cristobal-wetzig/orgs","repos_url":"https://api.github.com/users/cristobal-wetzig/repos","events_url":"https://api.github.com/users/cristobal-wetzig/events{/privacy}","received_events_url":"https://api.github.com/users/cristobal-wetzig/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/willdurand/EmailReplyParser/labels/Bug","name":"Bug","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-06-18T09:40:27Z","updated_at":"2015-06-18T14:05:53Z","closed_at":null,"body":"Hey. i noticed that the parser \"cleans\" the text from new lines. \r\n\r\nThis is problematic since it modifies the input. \r\n\r\nFor example if you want to print the output to html nl2br will not work.  This is a huge problem.\r\n\r\nCompare the fragment extracted:\r\n```\r\n\"2015-06-18 10:40 GMT+02:00 REDACTED : > Bounce! > > 2015-06-18 10:06 Cristobal Wetzig : >> > > >> > >> > Reply >> 2015-06-18 10:38 GMT+02:00 REDACTED : >> >> ok >> 2015-06-18 10:06 Centerpartiet :\\n>>> Reply\"\r\n```\r\nFrom the original\r\n```\r\n\"Pong\\r\\n\\r\\n2015-06-18 10:40 GMT+02:00 REDACTED :\\r\\n> Bounce!\\r\\n>\\r\\n> 2015-06-18 10:06 Cristobal Wetzig :\\r\\n>> > >\\r\\n>> >\\r\\n>> > Reply\\r\\n>> 2015-06-18 10:38 GMT+02:00 REDACTED :\\r\\n>>\\r\\n>> ok\\r\\n>> 2015-06-18 10:06 REDACTED :\\r\\n>>> Reply\"\r\n```"},"comment":{"url":"https://api.github.com/repos/willdurand/EmailReplyParser/issues/comments/113167324","html_url":"https://github.com/willdurand/EmailReplyParser/issues/34#issuecomment-113167324","issue_url":"https://api.github.com/repos/willdurand/EmailReplyParser/issues/34","id":113167324,"user":{"login":"cristobal-wetzig","id":478079,"avatar_url":"https://avatars.githubusercontent.com/u/478079?v=3","gravatar_id":"","url":"https://api.github.com/users/cristobal-wetzig","html_url":"https://github.com/cristobal-wetzig","followers_url":"https://api.github.com/users/cristobal-wetzig/followers","following_url":"https://api.github.com/users/cristobal-wetzig/following{/other_user}","gists_url":"https://api.github.com/users/cristobal-wetzig/gists{/gist_id}","starred_url":"https://api.github.com/users/cristobal-wetzig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cristobal-wetzig/subscriptions","organizations_url":"https://api.github.com/users/cristobal-wetzig/orgs","repos_url":"https://api.github.com/users/cristobal-wetzig/repos","events_url":"https://api.github.com/users/cristobal-wetzig/events{/privacy}","received_events_url":"https://api.github.com/users/cristobal-wetzig/received_events","type":"User","site_admin":false},"created_at":"2015-06-18T14:05:53Z","updated_at":"2015-06-18T14:05:53Z","body":"Ok!\r\nLet me try harder. I have a similar to this string lets call it $body:\r\n```\r\n2015-06-18 10:42 GMT+02:00 REDACTED <mail@mail.com>:\r\n> ping\r\n>\r\n> 2015-06-18 10:06 Cristobal Wetzig <cristobal.wetzig@relationdesk.com>:\r\n>> > >>> Reply\r\n>> >> 2015-06-18 10:06 REDACTED <mail@mail.com>:\r\n>> >> ok\r\n>> >>\r\n>> >> 2015-06-18 10:38 GMT+02:00 REDACTED <fraga@centerpartiet.se>:\r\n>> >> > Reply\r\n>> >> >\r\n>> >> > >\r\n>> > 2015-06-18 10:06 Cristobal Wetzig <cristobal.wetzig@relationdesk.com>:\r\n>> >\r\n>> > Bounce!\r\n>> 2015-06-18 10:40 GMT+02:00 REDACTED <mail@mail.com>:\r\n>>\r\n>> Pong\r\n>> 2015-06-18 10:06 REDACTED <mail@mail.com>:\r\n>>> Bounce!\r\n>>> 2015-06-18 10:06 Cristobal Wetzig <cristobal.wetzig@relationdesk.com>:\r\n>>>> >>> >\r\n>>>> >\r\n>>>> > Reply\r\n>>>> 2015-06-18 10:38 GMT+02:00 REDACTED <mail@mail.com>:\r\n>>>>\r\n>>>> ok\r\n>>>> 2015-06-18 10:06 REDACTED <mail@mail.com>:\r\n>>>>> Reply\r\n```\r\nIf you look at the raw string it contains a bunch of  newlines \\n and \\r\r\n\r\nSomething like this:\r\n```\r\n\r\n\"Pong\\r\\n\\r\\n2015-06-18 10:40 GMT+02:00 REDACTED :\\r\\n> Bounce!\\r\\n>\\r\\n> 2015-06-18 10:06 Cristobal Wetzig :\\r\\n>> > >\\r\\n>> >\\r\\n>> > Reply\\r\\n>> 2015-06-18 10:38 GMT+02:00 REDACTED :\\r\\n>>\\r\\n>> ok\\r\\n>> 2015-06-18 10:06 REDACTED :\\r\\n>>> Reply\"\r\n```\r\n\r\n```php\r\n$email_parser = new \\EmailReplyParser\\Parser\\EmailParser();\r\n$fragments = $email_parser->parse($body);\r\n foreach ($fragments->getFragments() as $fragment) {\r\n        if ($fragment->isHidden() && !$fragment->isEmpty()) {\r\n          //Fragment content will contain A\r\n\r\n$fragment->getContent()\r\n      }\r\n}\r\n```\r\n\r\nA:\r\nThe fragment will loose \"\\r\\n\" that was contained in the original $body. \r\n\r\n\r\n```\r\n\"2015-06-18 10:40 GMT+02:00 REDACTED : > Bounce! > > 2015-06-18 10:06 Cristobal Wetzig : >> > > >> > >> > Reply >> 2015-06-18 10:38 GMT+02:00 REDACTED : >> >> ok >> 2015-06-18 10:06 Centerpartiet :\\n>>> Reply\"\r\n```\r\n\r\n\r\n\r\n"}}