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

fix: ensure windows newlines don't break panels #6254

Merged
merged 1 commit into from
Jan 7, 2022
Merged

Conversation

stephanegigandet
Copy link
Contributor

some producers have imported ingredients lists with \r\n sequences, and that broke the JSON used by knowledge panels.

this fixes the generation of the panels.

we probably need another fix to normalize newlines when we edit products / import data.

@stephanegigandet stephanegigandet added the 📖 Knowledge Panels https://wiki.openfoodfacts.org/Knowledge_panels label Jan 7, 2022
@stephanegigandet stephanegigandet requested a review from a team as a code owner January 7, 2022 08:58
@@ -179,7 +179,8 @@ The function converts the multiline string into a single line string.

sub convert_multiline_string_to_singleline($) {
my $line = shift;
$line =~ s/\n/\\n/sg;
# \R will match all Unicode newline sequence
$line =~ s/\R/\\n/sg;
Copy link
Member

Choose a reason for hiding this comment

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

wow this \R character set is cool :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just discovered it ;) We probably could look for instances of \n and replace them.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 7, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

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

LGTM

@stephanegigandet stephanegigandet merged commit 74e9b3a into main Jan 7, 2022
@stephanegigandet stephanegigandet deleted the newlines branch January 7, 2022 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📖 Knowledge Panels https://wiki.openfoodfacts.org/Knowledge_panels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants