Repository navigation
Comparing changes
Open a pull request
base repository: apache/roller
base: master
head repository: apache/roller
compare: template-limits
- 20 commits
- 26 files changed
- 1 contributor
Commits on Nov 18, 2026
-
Bound weblog template rendering and keep templates and macros per weblog
A render now stops with a logged error, and the request fails as for other rendering errors, once it writes more than rendering.maxOutputChars characters (10 MB by default) or runs longer than rendering.maxRenderSeconds (30 by default). The output writer, #foreach, method calls, iteration and every inserted value check these limits, so loops that write nothing and strings built up in memory stop as well. #foreach also stops after 100,000 passes, and String.repeat is not offered to templates. While a weblog is rendered, #parse and #include load only that weblog's own stored templates. The public error pages no longer show template ids; they stay in the log, and the message names the template instead. Macros defined inline in a template are now local to that template and the render it starts, so two weblogs can define macros of the same name and an edited macro takes effect on the next render. Library macros stay global, and macros still reach between a page and the templates it includes.
Configuration menu - View commit details
-
Copy full SHA for 1973f42 - Browse repository at this point
Copy the full SHA 1973f42View commit details -
Stop string calls from templates that would build a string past the o…
…utput limit before they run String.replace, replaceAll, replaceFirst, concat, toUpperCase and toLowerCase, $utils.replace, and StringBuilder and StringBuffer growth methods now work out the longest string they can build before running, and the render stops with the output limit error when that is over the limit. String.format, formatted, join and indent are not offered to templates, like String.repeat, along with any other String method returning a string whose length can't be worked out from the call. Ordinary replaces and other string calls work as before.
Configuration menu - View commit details
-
Copy full SHA for c3de58a - Browse repository at this point
Copy the full SHA c3de58aView commit details -
Keep strings built in memory, macro calls and regular expressions ins…
…ide the render limits String literals such as "$a$b", the + operator, and #define blocks or macro bodies used as strings now stop at the output limit while the string is built, through a parser (RenderLimitParser, set as parser.class) that swaps in nodes which count what they write into a buffer and check the length of two strings before + joins them. Variables set from a template may hold no string longer than the limit. Every variable read and write and every macro call now checks the render deadline, so a recursive macro that writes nothing and calls no methods stops in time, and regular expressions given to String.matches, replaceAll, replaceFirst and split check the deadline as they run, so a slow expression stops with the render. RollerResourceLoader now refuses to start with resource.loader.roller.cache=true, which each weblog rendering only its own templates relies on.
Configuration menu - View commit details
-
Copy full SHA for 1879cd4 - Browse repository at this point
Copy the full SHA 1879cd4View commit details -
Check regex replaces against the output limit as they run, and drop t…
…he context checks replaceAll and replaceFirst now check the output limit before each replacement instead of refusing any call whose worst case over the whole string is over the limit, so a replace with group references such as $s.replaceAll('(\d)', '<$1>') on a long string works again. The arguments of the regular expression methods are converted the way Velocity converts them. RenderLimitContext is removed: every block render already writes to the counted output, which checks the deadline, so a macro that writes nothing still stops in time, and strings built by literals and + are now checked where they are built.Configuration menu - View commit details
-
Copy full SHA for a15d8c3 - Browse repository at this point
Copy the full SHA a15d8c3View commit details -
Configuration menu - View commit details
-
Copy full SHA for e882061 - Browse repository at this point
Copy the full SHA e882061View commit details
Commits on Nov 19, 2026
-
Keep template locations on swapped-in nodes and count only the split …
…pieces that are kept The nodes RenderLimitParser swaps in were built after the parser had let go of the template it was parsing, so they had no template. Velocity asks a node for its template name when it reports a problem, which turned harmless templates such as #set($x = $undefined + 1) and a macro that recurses too deeply into a NullPointerException. The replacement nodes now take the template from the node they replace. A split with the default limit of 0 drops trailing empty pieces, but the piece count included them, so a string ending in many delimiters was refused even though split would have returned few pieces or none. DeadlineRegex now does the split itself in one pass, holding empty pieces back until a piece that isn't empty follows, so trailing empty pieces are neither counted nor allocated and the expression only runs once. The comments above the render limit settings in velocity.properties now describe each setting once.
Configuration menu - View commit details
-
Copy full SHA for 439242b - Browse repository at this point
Copy the full SHA 439242bView commit details
Commits on Nov 20, 2026
-
Bound expanding $utils calls before they run and stop over-counting c…
…ase changes The pre-call output bound covered $utils.replace only, so $utils.escapeHTML, escapeXML, escapeJavaScript, encode, hexEncode, autoformat and the other String-returning $utils methods could build a result many times the output limit before the length check ran. StringGrowth now bounds each of them before the call by counting only the characters that method can expand, and refuses a $utils method added later that returns a string until it is listed. The case-change bound was three times the length, which refused toUpperCase on a large ASCII string whose result fits the limit. It now adds two characters only for each character outside ASCII. DeadlineRegex also checks the text after the last replacement against the limit before appendTail copies it, instead of after.
Configuration menu - View commit details
-
Copy full SHA for 66d58c4 - Browse repository at this point
Copy the full SHA 66d58c4View commit details -
Count only the characters escapeHTML and escapeXML expand
The escapeHTML and escapeXML bounds counted every character outside ASCII as an entity, so large text in Cyrillic, CJK and most other scripts, which those escapers leave alone, was refused. StringGrowth now finds the characters each escaper expands by escaping each char once, and counts only those.
Configuration menu - View commit details
-
Copy full SHA for b7b9c1a - Browse repository at this point
Copy the full SHA b7b9c1aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 29a8b9e - Browse repository at this point
Copy the full SHA 29a8b9eView commit details -
Read stored templates as text instead of encoding and decoding them
RollerResourceLoader turned each stored template into bytes in the template encoding and read them back with the platform's default charset, which changes text outside ASCII when the two differ. The template is already a string, so it is now read with a StringReader.
Configuration menu - View commit details
-
Copy full SHA for 9844fa5 - Browse repository at this point
Copy the full SHA 9844fa5View commit details -
Parse templates with many nodes in linear time
RenderLimitParser moved each node's children to its replacement from the first to the last, so the child array grew by one on every move. They are now moved last first, and the array is allocated once.
Configuration menu - View commit details
-
Copy full SHA for fdf4801 - Browse repository at this point
Copy the full SHA fdf4801View commit details -
Shorten long template error messages in the log and on the error page
A template error can quote a value from the template in full, such as a long string passed to a method. The log line and the error page now show the first 1,000 characters, and the log line stays on one line.
Configuration menu - View commit details
-
Copy full SHA for 71c3d6a - Browse repository at this point
Copy the full SHA 71c3d6aView commit details -
Count only the characters a case change or an escape really grows
The bounds for toUpperCase and toLowerCase counted every character outside ASCII as tripling, and escapeHTML and escapeXML charged every escaped character with the longest entity, so large Cyrillic or CJK text, or HTML near the limit, was refused although the result would fit. Each character's growth is now looked up in a table built by running the methods on it, in the locales whose case rules differ. The date format test now checks every locale. Its pattern used letters SimpleDateFormat rejects, so it had been checking none.
Configuration menu - View commit details
-
Copy full SHA for 540cb37 - Browse repository at this point
Copy the full SHA 540cb37View commit details -
Refuse regular expressions that repeat a part that can match an empty…
… string, and count only the groups a replacement uses - An expression with a part that can match empty in more than one way at the same place can try a very large number of ways without reading the text, so the deadline check in DeadlineText never runs. checkPattern refuses a group or assertion that can match empty followed by a quantifier, and a group with two alternatives that can match empty. Pattern itself is used to try whether a part can match empty. - replaceAll and replaceFirst with a null replacement now run under the deadline too, and fail as the String methods do. - A replacement is counted by the lengths of the groups it refers to, so a replace that moves text around in a string near the limit is no longer refused. - String.splitWithDelimiters and lines aren't offered to templates, since DeadlineRegex doesn't run them. - The comments no longer say Velocity converts arguments. It finds no method for a call whose arguments don't fit, so the conversions for those calls are gone.
Configuration menu - View commit details
-
Copy full SHA for 3b3d5bd - Browse repository at this point
Copy the full SHA 3b3d5bdView commit details -
Fail the render when a #foreach runs past 100,000 passes
Velocity's directive.foreach.max_loops ends a loop without an error, so a page cut short by it was served and cached as if it were whole. RollerForeach now fails the render on the pass after the 100,000th, like the other limits, and the property is gone from velocity.properties. A loop of exactly 100,000 passes still completes. The tests' check that Roller's limit, not the test's own ceiling, stopped a render followed getCause, which RenderingException doesn't set, so it never saw the ceiling. It now follows the root cause.
Configuration menu - View commit details
-
Copy full SHA for cbf0c54 - Browse repository at this point
Copy the full SHA cbf0c54View commit details -
Count the strings and list items a render builds, and check lists, ma…
…ps and numbers before a call runs The output limit stops what a template writes, but not what it keeps in memory, or what one call builds before its result is checked. - A render may build at most ten times rendering.maxOutputChars characters of strings, counted where they are built (string literals, + and string calls), and add at most 1,000,000 items to lists and maps or get them from split calls. A session started inside another one shares its budget. - A list or map is measured as text, without building the text, before it is inserted, passed to toString, String.valueOf or +, or compared with a string by == or !=. - addAll and putAll are checked against the item budget before they copy anything. containsAll, removeAll and retainAll are refused when they would compare more than 10,000,000 pairs of elements. - Numbers stop at 100,000 bits: pow, the shifts, the bit setters and * are checked before they run, and primality tests aren't offered. - $utils.split is refused when it would return more pieces than a #foreach can visit, as String.split already was. - A Class object offers only getName, so String.format and join can't be reached as static methods. - An error from a regular expression call, such as a replacement naming a group that doesn't exist, shows the template error page again instead of failing the page. - A blank or non-numeric rendering.maxOutputChars or rendering.maxRenderSeconds falls back to the default with a warning instead of failing every page, and the limit messages say which limit was reached.
Configuration menu - View commit details
-
Copy full SHA for 5b823f2 - Browse repository at this point
Copy the full SHA 5b823f2View commit details -
Bound $utils.addNofollow for its jsoup implementation
addNofollow now parses the HTML with jsoup and writes it out again, adding the rel to links that lack it, closing tags, quotes, escapes, and the tbody and tr a table cell implies. The old bound only counted links that already had rel="nofollow", so it was no longer an upper bound. Text with a link may now be at most a ninth of the output limit, above the most jsoup was seen to grow it (8.25 times, for a td in a table), and text without a link is returned as it is.
Configuration menu - View commit details
-
Copy full SHA for 088841d - Browse repository at this point
Copy the full SHA 088841dView commit details -
Describe the render budget and the new template refusals in CHANGES
The #317 entry now says that a long #foreach fails the render rather than stopping, lists the budget for strings, list items and numbers, and names the String methods and class calls templates can't use.
Configuration menu - View commit details
-
Copy full SHA for 9ad3bbe - Browse repository at this point
Copy the full SHA 9ad3bbeView commit details -
Measure map entries and appended lists as text, and count copied list…
… items - A map entry, such as one from entrySet(), is measured as key=value like a map, so a large list inside one is refused before it is printed. - toArray and clone on a list or map count the items they copy against the budget before they run. - StringBuilder.append and insert count a list or map passed as an Object by its text. - Only addAll and putAll count the items of a list passed to them, so adding a large list as one item is one item. - Whether part of a regular expression can match empty no longer depends on sample texts: lookarounds, anchors and boundaries count as matching empty, and the part is also tried in comments mode, which an inline (?x) may have turned on. - The tests use sizes just over the limits.
Configuration menu - View commit details
-
Copy full SHA for ca9614f - Browse repository at this point
Copy the full SHA ca9614fView commit details -
Stop offering $utils.addNofollow to templates
No bundled theme or template calls $utils.addNofollow, and since it now parses and rewrites the HTML with jsoup, how long its result can be can't be worked out from the input. UtilitiesModel no longer has the method, so a template that calls it gets the call written out as it is, like the String methods templates can't use, and the bound on its input is gone. Comments still get nofollow added through Utilities.addNofollow, and the template guide no longer lists the method.
Configuration menu - View commit details
-
Copy full SHA for 694131f - Browse repository at this point
Copy the full SHA 694131fView commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff master...template-limits