Skip to content

fix(jruby): serialize entity refs or the replacement text, not both#3272

Merged
flavorjones merged 1 commit intomainfrom
3270-jruby-entity-ref
Jul 3, 2024
Merged

fix(jruby): serialize entity refs or the replacement text, not both#3272
flavorjones merged 1 commit intomainfrom
3270-jruby-entity-ref

Conversation

@flavorjones
Copy link
Member

@flavorjones flavorjones commented Jul 3, 2024

What problem is this PR intended to solve?

Two things getting fixed here:

  1. We were not calling setFeature(FEATURE_NOT_EXPAND_ENTITY, ...) correctly. It defaults to true, and we were conditionally setting it to true. Instead, let's just explicitly set this feature (and the other features we care about) to avoid mistaken assumptions about the default.

  2. We were rendering the children of the EntityReference, which contains the replacement text, as well as the EntityReference itself. We should only ever render one or the other. If NOENT is false, though, there won't be any EntityReferences in the DOM. So: if we encounter an EntityReference, don't render its children.

See https://xerces.apache.org/xerces-j/features.html section on create-entity-ref-nodes for a deeper explanation of the parser behavior.

Closes #3270

Have you included adequate test coverage?

Yes

Does this change affect the behavior of either the C or the Java implementations?

This fixes a bug in the Java implementation, so it behaves like the C impl.

Two things getting fixed here:

1. We were not calling `setFeature(FEATURE_NOT_EXPAND_ENTITY, ...)` correctly. It defaults to true, and we were conditionally setting it to true. Instead, let's just explicitly set this feature (and the other features we care about) to avoid mistaken assumptions about the default.

2. We were rendering the children of the EntityReference, which contains the replacement text, as well as the EntityReference itself. We should only ever render one or the other. If NOENT is false, though, there won't be any EntityReferences in the DOM. So: if we encounter an EntityReference, don't render its children.

See https://xerces.apache.org/xerces-j/features.html section on `create-entity-ref-nodes` for a deeper explanation of the parser behavior.

Closes #3270
@flavorjones flavorjones force-pushed the 3270-jruby-entity-ref branch from 12fd018 to aad5c90 Compare July 3, 2024 13:43
@flavorjones flavorjones merged commit 0e9cf15 into main Jul 3, 2024
@flavorjones flavorjones deleted the 3270-jruby-entity-ref branch July 3, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] XML entity codes are printed along with expansion in to_s on JRuby

1 participant