snoopdave commented on code in PR #228:
URL: https://github.com/apache/roller/pull/228#discussion_r4394337453
##########
app/src/main/java/org/apache/roller/weblogger/util/Utilities.java:
##########
@@ -183,9 +183,12 @@ public static String removeHTML(String str, boolean
addSpace) {
start = endTag + 1;
beginTag = str.indexOf('<', start);
}
- // if no endTag found, get rest of str and break
+ // if no endTag found, the rest is text unless it starts a tag,
+ // which a browser would still parse as markup
else {
- ret.append(str.substring(beginTag));
+ if (!startsTag(str, beginTag)) {
Review Comment:
**Important:** The unterminated-tail branch only inspects the `<` that
begins the tail — a tag-starting `<` later in the kept remainder still survives
verbatim: `removeHTML("a < b <img src=x", false)` returns `"a < b <img src=x"`,
because the first `<` is followed by a space (not a tag) so the whole tail is
appended without further scanning. The main-menu output is now escaped so that
path is covered, but `removeHTML` is also the input filter for `WeblogCategory`
name/description, `WeblogEntry` summary, `WeblogCommentRequest` fields and
`UtilitiesModel` — for those callers the tail markup still passes through.
Consider continuing the scan instead of breaking: when `!startsTag`, append
just the `<`, advance past it and keep looping, so any later tag-starting `<`
is dropped too. Worth a test either way to pin the chosen behavior.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]