Skip to content

Set the DOM encoding to UTF-8 when it is not specified in a feed's xml declaration#113

Merged
froschdesign merged 3 commits intolaminas:2.26.xfrom
bramley:no_encoding_unit_test
Mar 3, 2026
Merged

Set the DOM encoding to UTF-8 when it is not specified in a feed's xml declaration#113
froschdesign merged 3 commits intolaminas:2.26.xfrom
bramley:no_encoding_unit_test

Conversation

@bramley
Copy link
Contributor

@bramley bramley commented Feb 15, 2026

Q A
Documentation no
Bugfix no
BC Break no
New Feature no
RFC no
QA yes

Description

A unit test to demonstrate the problem that I raised in issue #112. Output of phpunit

duncan@duncan-OptiPlex-990 ~/Development/GitHub/laminas-feed $ phpunit --group LaminasRATOMCONTENT
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

  Warning - The configuration file did not pass validation!
  The following problems have been detected:

  Line 16:
  - Element 'source': This element is not expected.

  Test results may not be as expected.


....E....                                                           9 / 9 (100%)

Time: 00:00.019, Memory: 36.28 MB

There was 1 error:

1) LaminasTest\Feed\Reader\Entry\AtomStandaloneEntryTest::testGetsContentFromAtom10XhtmlNamespacedNoEncoding
TypeError: DOMDocument::__construct(): Argument #2 ($encoding) must be of type string, null given

/home/duncan/Development/GitHub/laminas-feed/src/Reader/Extension/Atom/Entry.php:113
/home/duncan/Development/GitHub/laminas-feed/src/Reader/Entry/Atom.php:97
/home/duncan/Development/GitHub/laminas-feed/test/Reader/Entry/AtomStandaloneEntryTest.php:262

ERRORS!
Tests: 9, Assertions: 8, Errors: 1.

@bramley bramley force-pushed the no_encoding_unit_test branch from 7a30c0e to 3d856b3 Compare February 15, 2026 20:18
@froschdesign froschdesign added the Bug Something isn't working label Feb 15, 2026
@froschdesign froschdesign marked this pull request as draft February 15, 2026 20:29
@froschdesign
Copy link
Member

@bramley
Would you also add a fix?
Thanks in advance! 👍🏻

@bramley
Copy link
Contributor Author

bramley commented Feb 16, 2026

Fix added here.

@bramley bramley force-pushed the no_encoding_unit_test branch 2 times, most recently from 68ecb39 to fb8532f Compare February 20, 2026 16:09
…an encoding.

Obvious fix.

Signed-off-by: Duncan Cameron <3147688+bramley@users.noreply.github.com>
Signed-off-by: Duncan Cameron <3147688+bramley@users.noreply.github.com>
Signed-off-by: Duncan Cameron <3147688+bramley@users.noreply.github.com>
@bramley bramley force-pushed the no_encoding_unit_test branch from fb8532f to e045c14 Compare February 20, 2026 16:25
@froschdesign froschdesign changed the title Unit test to get Atom feed entry content when document does not have an encoding Set the DOM encoding to UTF-8 when it is not specified in a feed's xml declaration Mar 3, 2026
@froschdesign froschdesign changed the base branch from 2.27.x to 2.26.x March 3, 2026 09:52
@froschdesign froschdesign self-assigned this Mar 3, 2026
@froschdesign froschdesign marked this pull request as ready for review March 3, 2026 09:53
@froschdesign froschdesign added this to the 2.26.1 milestone Mar 3, 2026
@froschdesign froschdesign merged commit 8b651d7 into laminas:2.26.x Mar 3, 2026
13 checks passed
@froschdesign
Copy link
Member

@bramley
Thank you for your time and this contribution! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fatal error when accessing a content element of type xhtml in an atom feed that doesn't have an explicit xml encoding

2 participants