Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#46922 closed defect (bug) (fixed)

Atom feeds should not have extra white space in date constructs

Reported by: josephwa's profile josephwa Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.2 Priority: normal
Severity: normal Version: 5.1
Component: Feeds Keywords:
Focuses: Cc:

Description

PThe Atom format's RFC doesn't allow for white space in date elements:

Note that there MUST NOT be any white space in a Date construct or in
any IRI. Some XML-emitting implementations erroneously insert white
space around values by default, and such implementations will emit
invalid Atom Documents.

However, this was introduced in #41057 when feed-atom-comments.php and feed-atom.php were rewritten.

Specifically, by:

-       <updated><?php
+       <updated>
+       <?php

This would cause a strict consumer to reject feeds generated by 5.1.

Attachments (2)

Change History (8)

#1 @SergeyBiryukov
6 years ago

  • Component changed from General to Feeds
  • Milestone changed from Awaiting Review to Future Release

Related: #46575

0001-Remove-white-space-from-Atom-s-updated.patch is not enough, as running composer format on src/wp-includes/feed-atom-comments.php still results in the extra tabs. Since #44600, coding standards are enforced, and auto-fixable issues cause build failures in Travis.

Apparently this needs to be adjusted upstream in WPCS: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.

Version 0, edited 6 years ago by SergeyBiryukov (next)

#2 @josephwa
6 years ago

Changing the generic wpcs sounds like a major change; as a fairly blunt instrument, I've attached a patch that uses phpcs:ignore to allow those lines through.

Another option is to write those elements on a single line:

        <updated><?php echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', get_last_build_date(), false ) : date( 'Y-m-d\TH:i:s\Z' ); ?></updated>

If those are the only files with that issue, a local fix may be acceptable.

#3 @SergeyBiryukov
6 years ago

  • Milestone changed from Future Release to 5.2

#4 @SergeyBiryukov
6 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 45208:

Feeds: Remove whitespace from <updated> elements in Atom feeds.

Per Atom format's RFC, there must not be any whitespace in a Date construct or in any IRI.

Props josephwa.
Fixes #46922.

#5 @SergeyBiryukov
6 years ago

In 45215:

Feeds: Amend [45208] to avoid phpcs:ignore.

See #46922.

#6 @desrosj
5 years ago

#46473 was marked as a duplicate.

Note: See TracTickets for help on using tickets.