mraible opened a new pull request, #356:
URL: https://github.com/apache/roller/pull/356

   This builds on #353 (which builds on #318, where jsoup comes in), so its 
diff includes their commits until they merge. The new commit is the last one.
   
   When `weblogAdminsUntrusted` is true, `HTMLSanitizer` cleans entry text, 
titles, summaries, user names, bookmark names and weblog taglines. It was a 
528-line regular-expression parser from Open Lab (2009), and CodeQL flags it 
six times for polynomial ReDoS (alerts 89–94). In the new test, a few kilobytes 
of crafted markup took the old class **43.6 seconds**; it takes **28 ms** now.
   
   It now uses jsoup's `Cleaner` with a `Safelist` that keeps the same rules:
   
   - the same tags, without the forbidden `script`, `object`, `embed`, `link`, 
`style`, `form` and `input`
   - links to http, https and mailto addresses, and images from http and https 
or image data that `InlineImageData` accepts
   - `width` and `height` only as pixels or percentages
   - `style` only when it can't load anything or run script (no `url()`, 
`image-set()`, `expression()`, `@import`, behaviors, escapes or comments)
   - no event handlers
   
   What changes:
   
   - Attributes that aren't listed are removed instead of being kept 
HTML-encoded. The list covers the common ones: `class`, `id`, `title`, `lang`, 
`dir`, `align`, `alt`, `border`, `colspan`, `rowspan`, `valign`, `summary`, 
`cellpadding`, `cellspacing`, `start`, `type`, `name`.
   - The unused helpers (`isSanitized`, `getText`, `sanitizer`, `encode`, 
`htmlEncode*`, `convertLineFeedToBR`, `removeLineFeed`, `replaceAllNoRegex`) go 
with the old parser, so none of the Open Lab code is left.
   
   The new HTMLSanitizerTest covers kept markup, scripts, styles, event 
handlers, `javascript:` and relative links, iframes, plugins, forms, SVG, 
unsafe styles and sizes, and the slow inputs. The existing inline image tests 
pass unchanged, and so does the full unit suite (774 tests).
   
   6.1.x keeps its current sanitizer.


-- 
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]

Reply via email to