Skip to content
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

Bug 1891527 - In Bugmail & Bug History for User Story edits, there's a warning about 'No newline at end of file' for user-entered values, even though the submitted value included a trailing newline #2234

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

dklawren
Copy link
Collaborator

I updated the code to add back the stripped newlines from the user story value before performing the diff if the newlines are missing. This fixes the issue with the warning being added to the diff output.

…a warning about 'No newline at end of file' for user-entered values, even though the submitted value included a trailing newline
@dklawren dklawren requested a review from cgsheeh April 19, 2024 19:52
Comment on lines +72 to +73
my $old_value = $changes->{cf_user_story}->[0];
my $new_value = $changes->{cf_user_story}->[1];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the newline is stripped by the time it reaches this variable in Perl, could the issue be that the JS on the front-end is stripping the newline? Fixing it there is probably the more correct solution, but this works too and the bug probably doesn't warrant much more of a time investment. :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the newline is stripped by the time it reaches this variable in Perl, could the issue be that the JS on the front-end is stripping the newline? Fixing it there is probably the more correct solution, but this works too and the bug probably doesn't warrant much more of a time investment. :)

Ideally that would be better but internally BMO is treating the user story field as any other freetext custom field. Therefore, before a value is stored in the DB it is trimmed of all whitespace at the beginning and end of the string. The regex used is /\s+$/ which also includes newlines as well as spaces. Rather than add a new data type just for story with a custom validation code function that doesn't remove newlines, it was simpler to just add the newline temporarily when doing the diff action.

@dklawren dklawren merged commit af1be46 into mozilla-bteam:master Apr 22, 2024
17 checks passed
@dklawren dklawren deleted the 1891527 branch April 22, 2024 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants