Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Conversation

@Tpt
Copy link
Collaborator

@Tpt Tpt commented Feb 13, 2022

DOMDocument::createElement escapes '<' and '>' but not '&'...

DOMDocument::createElement escapes '<' and '>' but not '&'...
@samwilson samwilson merged commit 14f5b46 into main Feb 14, 2022
@samwilson samwilson deleted the atom-amp branch February 14, 2022 00:45
}

$node = $dom->createElement( $name, $value );
$node = $dom->createElement( $name, str_replace( '&', '&amp;', $value ) );
Copy link
Member

Choose a reason for hiding this comment

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

Actually, I think another way to do this might be to set textContent directly, e.g.:

		$node = $dom->createElement( $name );
		$node->textContent = $value;

I'm not sure if there are other considerations, so probably it's fine to handle the one-off case you've found.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It sounds much better. Thank you! I create #398 to do it.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants