diff --git a/Tests/LibXML/TestParser.cpp b/Tests/LibXML/TestParser.cpp
index f763e9173ef..abf416c9867 100644
--- a/Tests/LibXML/TestParser.cpp
+++ b/Tests/LibXML/TestParser.cpp
@@ -29,3 +29,15 @@ TEST_CASE(character_reference_integer_overflow)
return Test::Crash::Failure::DidNotCrash;
});
}
+
+TEST_CASE(predefined_character_reference)
+{
+ XML::Parser parser("Well hello &, <, >, ', and "!"sv);
+ auto document = MUST(parser.parse());
+
+ auto const& node = document.root().content.get();
+ EXPECT_EQ(node.name, "a");
+
+ auto const& content = node.children[0]->content.get();
+ EXPECT_EQ(content.builder.string_view(), "Well hello &, <, >, ', and \"!");
+}
diff --git a/Userland/Libraries/LibXML/Parser/Parser.cpp b/Userland/Libraries/LibXML/Parser/Parser.cpp
index 3dea6909c39..c997c4c2cb6 100644
--- a/Userland/Libraries/LibXML/Parser/Parser.cpp
+++ b/Userland/Libraries/LibXML/Parser/Parser.cpp
@@ -862,7 +862,7 @@ ErrorOr Parser::parse_content()
if (auto char_reference = reference.get_pointer())
append_text(*char_reference);
else
- TRY(resolve_reference(reference.get(), ReferencePlacement::Content));
+ append_text(TRY(resolve_reference(reference.get(), ReferencePlacement::Content)));
goto try_char_data;
}
if (auto result = parse_cdata_section(); !result.is_error()) {