Repository navigation
Escape user names, comments, commenter details and tag names where they're output - #318
Merged
Merged
Conversation
UserWrapper now returns screen and full names as HTML-escaped text, encoding them exactly once whether they were stored as typed or already encoded by the sanitizer, and the built-in feed macros turn them back into text before XML-escaping them for Atom author names and RSS dc:creator. HTML comment notification emails escape the commenter's name and email address. WeblogEntryCommentWrapper escapes HTML comments when the HTMLSubset plugin isn't both configured and listed on the comment, and its Javadoc now describes what getContent does. Utilities.transformToHTMLSubset and addNofollow find each link's closing bracket with one forward search and stop when none is left, so their time is linear in the input, and addNofollow now adds rel="nofollow" to links that don't already have it. TagDataServlet writes tag names and the weblog handle with JSON and XML escaping. The planet group pages pass handles and feed URLs to their delete handlers through data attributes, and JspOutputEncodingTest rejects property values inside inline event handlers. CommentDataServlet returns comment content as JSON, which Comments.jsp reads with jQuery's json data type, and UserDataServlet declares its plain text response.
WeblogEntryCommentWrapper.getContent now HTML-escapes any comment that isn't text/html with the HTMLSubset plugin applied, including comments without a content type.
snoopdave
reviewed
Nov 18, 2026
…isting rel values in addNofollow The comment feed macros and the media file feed now turn author names back into text with unescapeHTML before XML-escaping them, as the entry author macros do, so a name like "A & B" no longer shows as "A & B" in feed readers. FeedAuthorEscapingTest covers the Atom and RSS comment feeds and the media file feed. Utilities.addNofollow adds nofollow to a link's existing rel value instead of adding a second rel attribute, and a ">" inside a quoted attribute value no longer ends the link early. The linear-time test now allows 2 seconds so it doesn't fail on slow build machines.
Contributor
Author
|
A second review raised a few more points, now addressed in the latest commits:
|
addNofollow looked for rel= anywhere in the tag, so a link like <a href="/x" title='foo rel=external' rel="noopener"> had nofollow added to the title text while its real rel stayed followable. It now walks the tag's attributes while tracking quotes, the same way findTagEnd finds the end of the tag, and changes only a real rel attribute. A rel with no value gets rel="nofollow".
addNofollow now parses the HTML with jsoup 1.24.1 and adds nofollow to the rel attribute of each a element with an href, instead of scanning the markup by hand. Only a link's own rel is changed, and links with no href are left alone. Text with no links is returned as is. The result is jsoup's serialization of the fragment, so open tags are closed, attribute values are double-quoted, and a tag that never ends is dropped, as browsers do. Escaped text stays escaped. jsoup is credited in the binary LICENSE.
This was referenced Nov 18, 2026
A comment saved without a name, or a media file whose creator can't be found, made the comment and media file feeds print the template expression itself as the author, because unescapeHTML passed null through and Velocity prints a null reference as its source text. The template unescapeHTML helper now returns an empty string for null, as removeHTML does, so the author element is empty again.
snoopdave
reviewed
Nov 20, 2026
snoopdave
left a comment
Contributor
There was a problem hiding this comment.
Review of 6d9f0775e: The current diff addresses the earlier feed author encoding point. The corresponding fix in #347 is present here; the nofollow implementations differ by branch. I found no new correctness or test issue in this read-only review.
Earlier comments: 3 of 3 resolved.
No new issues found.
snoopdave
approved these changes
Nov 20, 2026
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.
Escaping and parsing fixes where names, comments and tags are output:
UserWrapperreturns screen and full names as HTML-escaped text, encoded exactly once whether they were stored as typed or already encoded by the sanitizer (weblogAdminsUntrusted). The built-in feed macros write them as plain text in Atom<author><name>and RSSdc:creator, and the comment feed macros and the media file feed do the same for comment and media file authors, so a name likeA & Bno longer shows asA & Bin feed readers.WeblogEntryCommentWrapper.getContentHTML-escapes any comment that isn'ttext/htmlwith the HTMLSubset plugin both configured and applied, including comments without a content type. Its Javadoc now says what it does.Utilities.transformToHTMLSubsetfinds each link's closing>with one forward search, so its time is linear in the input.addNofollowparses the HTML with jsoup, a new bundled dependency (1.24.1, listed inbinary-includes/LICENSE.txt). It now addsnofollowto links that lack it (it used to touch only links that already had it), adding it to a link's existingrelvalue rather than a secondrelattribute, and a>inside a quoted attribute value no longer ends the link early.TagDataServletJSON- and XML-escapes tag names and the weblog handle.data-*attributes, andJspOutputEncodingTestnow rejects property values inside inline event handlers.CommentDataServletGET returns JSON asapplication/json, andComments.jspreads it withdataType: "json"instead ofeval.UserDataServletsets an explicit content type.Tests:
UserWrapperTest,FeedAuthorEscapingTest(entry, comment and media file feeds),MailUtilCommentNotificationTest,TagDataServletTest, new cases inWeblogEntryCommentWrapperTest,UtilitiesTest,CommentDataServletTest,UserDataServletTestandJspOutputEncodingTest; fourteen of the original cases fail without the change. The linear-timeUtilitiesTestcase allows 2 seconds so it doesn't fail on slow build machines.mvn testpasses, and the Playwright database-login suite passes.CHANGES entries for this and the related fixes will come in one PR.
A further review pass added these fixes: