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

Jetpack: Stats: Fix csv trailing newline handling #39787

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Fix bug in #39665 related to a trailing newline in the CSV data.


2 changes: 1 addition & 1 deletion projects/plugins/jetpack/modules/stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,7 @@ function stats_get_remote_csv( $url ) {
*/
function stats_str_getcsv( $csv ) {
// @todo Correctly handle embedded newlines. Note, despite claims online, `str_getcsv( $csv, "\n" )` does not actually work.
$lines = explode( "\n", $csv );
$lines = explode( "\n", rtrim( $csv, "\n" ) );
return array_map(
function ( $line ) {
// @todo When we drop support for PHP <7.4, consider passing empty-string for `$escape` here for better spec compatibility.
Expand Down
Loading