Repository navigation
Conversation
Before Summernote starts, EntryEditor.jsp checks the entry's HTML with the new rich-editor-content.js, which parses it in an inert DOMParser document and looks for scripts, frames, plugins, document-level elements, noscript, SVG set and animate, on* attributes, and javascript: or vbscript: URLs in any attribute. When it finds any, the entry opens in the plain HTML textarea with a short notice, and media files are inserted into the textarea, since Summernote would start itself on any call. Other entries open in Summernote as before. The stored HTML isn't changed, and the plain text editor is unchanged.
… elements jQuery's html(), which Summernote uses to load an entry, keeps table cells, rows and captions found outside a table, while a full document parse drops them and their attributes. rich-editor-content.js now also checks the entry parsed as template contents, which keeps them, and treats <style> elements as active since they apply to the whole page. Media files inserted into the textarea fallback go at the cursor, or at the end when it has none.
This was referenced Nov 18, 2026
snoopdave
reviewed
Nov 18, 2026
… of the textarea, and test the rich editor check in a browser rich-editor-content.js now looks for javascript: and vbscript: URLs only at the start of URL attributes (href, src, action, formaction, xlink:href, data, poster, background, cite and each srcset candidate), so text such as title="JavaScript: The Good Parts" no longer opens an entry in the textarea. Entries with textarea, title, xmp, noembed, noframes or plaintext elements, or with markup that parses differently once serialized and parsed again (as the rich editor does for undo and code view), open in the textarea too. The textarea fallback now remembers whether the cursor has been placed, so a media file goes at the start when the cursor was put there, and at the end only when it never was. The new RichEditorContentIT in it-playwright loads the script into a blank page and checks entries that should open in the textarea, entries that should stay in the rich editor, and where media files are inserted. It needs no running Roller.
…arses the same way twice The serialize-and-parse-again check in rich-editor-content.js compared serialized HTML, so a <pre> starting with a blank line, which loses one leading newline each time it is parsed, opened in the textarea. It now compares the elements, their namespaces and attributes, and leaves text out. RichEditorContentIT checks that case.
Contributor
Author
|
A second review raised a few more points, now addressed in the latest commits:
|
…form controls in the textarea The rich editor loads an entry inside the entry form, where the parser ignores the start tag of another form, so the content check now also parses and re-parses the HTML inside a form and no longer misses markup that only becomes an element with an event handler there. Entries with a form, input, button or select element, or a formaction attribute, now open in the HTML textarea. The rich editor dropped a form's own tags on save, and such controls became part of the entry form, where they could be submitted with the entry or send it to another address. The check reads attributes and child nodes through the DOM prototypes, so a form control named attributes or firstChild can no longer hide its form's attributes from it. The leave-page warning is now attached on the first rich editor change only, instead of once more on every change, and the test that guards Summernote command calls matches single-quoted command names too. The check also reads the parsed document's body and calls its createElement and querySelectorAll through the DOM prototypes. In Firefox an image named body, createElement or querySelectorAll replaces that property on the parsed document, which made a harmless image with such a name open in the textarea and left the body comparison looking at the image instead of the body.
snoopdave
reviewed
Nov 20, 2026
snoopdave
left a comment
Contributor
There was a problem hiding this comment.
Review of d14eaded9: The earlier editor and cursor issues are resolved, and the production changes match #331. The new textarea path can miss the unsaved-edit warning while the field remains focused. #319 also has one MathML parser test case absent from #331; the other test differences follow the branches’ test frameworks.
Earlier comments: 5 of 5 resolved.
The textarea fallback installed the leave-page warning on change, which fires only after the field loses focus, so an author who typed and closed the tab while still in the field got no warning. It now listens for the first input event, and media insertion triggers input. The new user journey switches its weblog to the rich editor, opens an entry with a click handler in the textarea, and checks the warning is armed after typing and after inserting a media file.
mraible
added a commit
to mraible/roller
that referenced
this pull request
Nov 20, 2026
Adds bug-fix and behaviour-change entries for apache#313 to apache#319 and apache#321 to apache#323.
…aves them The content check parsed entries with DOMParser, a template and a div in a form, which only approximate how the rich editor loads them. DOMParser also parses without a doctype, in quirks mode, while the editor page is in standards mode, so the same HTML could become a different tree there. The check now builds what jQuery's html() builds, in an inert standards-mode document: in place in the rich editor inside the entry form, or, for HTML whose first tag is a table part or that has script, style or link tags, in a detached element inside the table elements jQuery adds, the way both jQuery 3 and 4 do it. It checks that tree and checks that loading its serialized HTML again, as undo does, gives the same elements. Leaving Summernote 0.9's code view removes some tags from the HTML, which can end a comment early, so the check also follows the serialized HTML through that filter, and HTML with an iframe tag anywhere in it, even in a comment, opens in the textarea. RichEditorContentIT now loads entries with the jQuery webjar for its check that what stays in the rich editor has no event handlers.
… attributes, in the textarea Summernote shows some text from the entry as HTML: its autolink parses a URL-like word as HTML when the author types a space after it, and Summernote 0.8's link popover does the same with a link's href. Entries with a URL-like word that has a < in it, or an href with a < in it, now open in the HTML textarea. Other text with < in it, such as code samples, stays in the rich editor. Bootstrap's data API acts on clicks anywhere in the page, and Bootstrap 3 loads a link into the dialog it names, so entries with data-toggle, data-target, data-dismiss, data-slide, data-slide-to or data-bs-* attributes open in the textarea too.
The check treated every element named title or meta as active, so an inline SVG with a <title> tooltip, or schema.org microdata written as <meta itemprop content>, opened in the HTML textarea. It now flags only an HTML <title>, and a <meta> unless it has itemprop and none of name, http-equiv and charset.
The notice used a doubled apostrophe, which shows as two unless the message goes through MessageFormat, and the page shows it without parameters. It now says cannot, which reads the same either way.
The leave-page warning was armed on the first edit only, and a submit removed it for good, so after a submit that was stopped before the page changed, later edits could be lost without a prompt. The submit handler now arms the warning again for the next edit, in the rich editor and in the HTML textarea.
…a command name The test that Summernote only starts after the content check matched calls that pass a quoted command name, so a call that passes a variable, no arguments or a second options object would not have been seen. It now matches every .summernote( call and expects exactly the init after the check and the guarded pasteHTML.
…path When the HTML has a script, style or link tag but doesn't start with a table part, jQuery 3 parses it without any wrapper, but the check added an empty <> around it, which left stray text in its parse. RichEditorContentIT covers an entry with a link tag in a comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before Summernote starts,
EntryEditor.jspchecks the entry with the newroller-ui/scripts/rich-editor-content.js. If the entry has HTML the rich editor would run or can't keep, it opens in the plain textarea with a notice instead of in Summernote. The entry's stored HTML is never changed, so embeds such as videos and widgets are kept, and the plain-text editor is unchanged.The check builds what jQuery's
html()builds when Summernote loads the entry, in an inert standards-mode document (document.implementation.createHTMLDocument), so resources don't load and nothing runs:<script,<styleor<link, in a detached element inside the table elements jQuery adds, both the way jQuery 3 does it (wrapping the HTML in tags) and the way jQuery 4 does it (parsing inside wrapper elements).In that tree it looks for:
object,embed,applet),base,link,style,noscript,textarea, HTMLtitle,xmp,noembed,noframes,plaintext, SVGset/animate, forms and form controls, andmetaunless it is microdata (itempropwithoutname,http-equivorcharset). An SVG<title>tooltip is fine.on*andformactionattributes, andjavascript:orvbscript:URLs at the start of URL attributes (href,src,action,formaction,xlink:href,data,poster,background,citeand eachsrcsetcandidate). Text such astitle="JavaScript: The Good Parts"doesn't count.data-toggle,data-target,data-dismiss,data-slide,data-slide-to,data-bs-*), which act on clicks anywhere in the page.hrefwith a<in it, and a URL-like word with a<in it, which autolink turns into a link when the author types a space after it. Code samples such asa < bstay in the rich editor.It then serializes the tree and loads it again, as undo does, and compares the elements, their namespaces and attributes (not the text, so a
<pre>starting with a blank line is fine). It also follows the HTML through Summernote 0.9's code view filter, which removes some tags when the author leaves code view, and opens HTML with an<iframeanywhere in it, even in a comment, in the textarea.Media inserted while the textarea is showing goes into the textarea, since Summernote starts itself on any call: at the cursor when one has been placed, including at the very start, and at the end otherwise. The leave-page warning is armed on the first edit, by typing in the textarea or a Summernote change, and armed again after a submit that keeps the page open.
This only applies to weblogs that use Summernote. Its editor id is
editor-xinha.jsp, so weblogs with an oldxinhaeditor value get Summernote and this check.plugins.defaultEditor=editor-summernote.jspmatches no editor, so other values that name an editor that no longer exists (such asekit) fall back to the first configured editor, the plain textarea. This PR doesn't change that lookup.Tests:
EntryEditorRichContentTestchecks that the page loads the script, that every.summernote(call is either the init after the check or the guardedpasteHTML, that the leave warning is armed again after a submit, and that the textarea fallback inserts media at the cursor.RichEditorContentITinit-playwrightloads the script into a blank page in Chromium, with no running Roller, and checks entries that must open in the textarea, entries that should stay in the rich editor, and where media files are inserted. It also loads entries with the jQuery 4.0.0 webjar (a new test dependency) and checks that whatever the check lets through has no event handlers once jQuery has loaded it.The CHANGES entry for this PR, added in #324, now also lists the other entries that open in the textarea: forms, some Bootstrap data attributes, a link or URL-like word containing
<, and an iframe or a tag that code view removes, even in a comment.