-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Newlines in custom data are shown as \n in emails #534
Conversation
What version of ACRA? |
4.9.1 I haven't tested yet with the current state of the repository. I'll do that now. |
@william-ferguson-au The probably also exists in the current code. I've updated the issue with some code. |
Yeah, looks like you need to transform the customData from \\n back to \n |
@william-ferguson-au I think I've fixed it with this pull request. Can you take a look? |
@@ -66,8 +66,12 @@ private String buildBody(@NonNull CrashReportData errorContent) { | |||
|
|||
final StringBuilder builder = new StringBuilder(); | |||
for (ReportField field : fields) { | |||
String value = errorContent.get(field); | |||
if (value != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe value can ever be null. If it is listed as a field then it should always have a value. And the previous code would have broken on line 74 with an NullPointerException.
@@ -66,8 +66,12 @@ private String buildBody(@NonNull CrashReportData errorContent) { | |||
|
|||
final StringBuilder builder = new StringBuilder(); | |||
for (ReportField field : fields) { | |||
String value = errorContent.get(field); | |||
if (value != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe value can ever be null. If it is listed as a field then it should always have a value. And the previous code would have broken on line 74 with an NullPointerException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. There is a de-facto null-value, which is AcraConstants.NOT_AVAILABLE, but a collector returning null would be a bug.
@@ -66,8 +66,12 @@ private String buildBody(@NonNull CrashReportData errorContent) { | |||
|
|||
final StringBuilder builder = new StringBuilder(); | |||
for (ReportField field : fields) { | |||
String value = errorContent.get(field); | |||
if (value != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe value can ever be null. If it is listed as a field then it should always have a value. And the previous code would have broken on line 74 with an NullPointerException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first implementation didn't have the null check, but I got a NullPointerException. I didn't look into it any further, but I think it might be because the "user comment" was null. I've seen that in the email that gets sent. StringBuilder.append
inserts "null" into the string if the argument is null, so I don't think anything will crash if a null is around.
Does this problem exist with the json implementation? See #523 If not, this would be another reason to adopt that structure. |
@F43nd1r Kevin has added you as team member, so you can merge in these and other changes. |
@william-ferguson-au thanks for that. But I think it won't change much on my workflow, as I won't be merging anything without talking about it with you and/or Kevin. While I would like to merge the json PR, I'll have to test it some more, as I noticed that the EmailSender will output some json, which should not be the case. |
Closing because the problem was solved with #523 |
Newlines are escaped in CustomDataCollector, presumably for a good reason somewhere else in the code. However, when I send a report via email, the custom data contains the escaped newlines (
\n
) in the custom data instead of real newlines. Is there just a step missing in EmailIntentSender?This is the code I'm using to update the custom data. I'm keeping a log by appending messages to a single custom data key.
I'm using version 4.9.1, but have also tested with the development version and the problem still exists.