Skip to content

Migration to rich text handler: All rich text containing <br> is considered invalid and returns no content #21

Description

@henrykuijpers
@Model(adaptables = Resource.class, adapters = BlockQuote.class)
@Getter
public class BlockQuote {
    private final String quote;
    private final String source;
    private final Link sourceLink;

    @Inject
    public BlockQuote(@NotNull @Self final RichTextHandler richTextHandler,
                      @NotNull @Self final LinkHandler linkHandler,
                      @Nullable @ValueMapValue(name = "quote", injectionStrategy = InjectionStrategy.OPTIONAL) final String quote,
                      @Nullable @ValueMapValue(name = "quotesource", injectionStrategy = InjectionStrategy.OPTIONAL) final String source,
                      @Nullable @ChildResource(name = "quote-source-link", injectionStrategy = InjectionStrategy.OPTIONAL) final Resource sourceLinkResource) {
        this.quote = richTextHandler.get(quote).buildMarkup();
        this.source = source;
        this.sourceLink = linkHandler.get(sourceLinkResource).build();
    }
}

For the input string <p>Test<br>Test</p> coming from the rich text editor, this.quote is being assigned the value null, because the <br> is not considered valid when there is no close tag for it.

The problem is that rich text handler is parsing the RTE output as XML instead of HTML. In XML, indeed, this is invalid, in HTML omitting the close tag is perfectly valid.

Under the hood, there is an exception thrown by JDOM2:

"org.jdom2.input.JDOMParseException: Error on line 2: The element type "br" must be terminated by the matching end-tag "</br>"."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions