Skip to content

Conversation

@lukaszlenart
Copy link
Member

@lukaszlenart lukaszlenart commented Nov 21, 2025

Summary

Resolves WW-5256 - Reduce size of generated HTML output from FreeMarker tag templates.

  • Add struts.freemarker.whitespaceStripping configuration option to control FreeMarker whitespace stripping (auto-disabled in devMode)
  • Add struts.compress.enabled configuration option for global compress tag control
  • Add <s:compress> tag to compress HTML output with force attribute to override settings
  • All new features tagged with @since 7.2.0

Test plan

  • Tests for whitespace stripping configuration
  • Tests for compression enabled/disabled globally
  • Tests for force attribute overriding global settings
  • All existing tests pass

🤖 Generated with Claude Code

lukaszlenart and others added 6 commits September 24, 2025 10:49
- Add struts.freemarker.whitespaceStripping configuration option
- Automatically disable whitespace stripping in devMode
- Add @SInCE 7.2.0 tags to new Compress component and configuration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add struts.compress.enabled configuration option
- Compress tag respects global setting unless force=true
- Add @SInCE 7.2.0 tag to new constant

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add tests for global compression disabled setting
- Add test for force attribute overriding global setting
- Update compress tag documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Test whitespace stripping enabled by default
- Test whitespace stripping disabled via configuration
- Test whitespace stripping disabled in devMode
- Test whitespace stripping enabled when not in devMode

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
lukaszlenart and others added 2 commits November 27, 2025 12:35
…ation

Replace complex CompressWriter (125 lines) with simple regex-based compression
(15 lines). Remove bufferSize parameter as buffering is no longer needed when
processing strings directly. Update tests to remove buffer-related test cases.

- Remove CompressWriter inner class and state machine
- Add compressWhitespace() static method using regex
- Remove bufferSize field and setter from Compress and CompressTag
- Remove 3 buffer-related tests from CompressTest
- Remove 1 buffer-related test from CompressTagTest
- All remaining 19 tests pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add documentation for the singleLine attribute in compress tag.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@lukaszlenart lukaszlenart force-pushed the feature/WW-5256-freemarker-compress branch from 0be3e9e to 2fa7671 Compare November 27, 2025 11:39
lukaszlenart and others added 3 commits November 27, 2025 14:58
Add configurable size limits and log truncation to prevent:
- DoS attacks via large input (configurable maxSize, default 10MB)
- Sensitive data exposure in logs (configurable logMaxLength, default 200 chars)
- ReDoS attacks via regex operations (50MB hard limit)

Adds new configuration constants:
- STRUTS_COMPRESS_MAX_SIZE for maximum compressible body size
- STRUTS_COMPRESS_LOG_MAX_LENGTH for maximum log content length

Includes implementation plan documentation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive test coverage for security enhancements:
- testMaxSizeLimit: verify size limit enforcement
- testMaxSizeDisabled: verify disabled limit behavior
- testLogTruncation: verify log truncation works correctly
- testVeryLargeInputSafety: verify 50MB hard limit protection
- testInvalidMaxSizeConfiguration: verify invalid config handling
- testInvalidLogMaxLengthConfiguration: verify invalid config handling

All tests use behavior-based assertions following existing patterns.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Update @StrutsTag annotation description to include security considerations:
- DoS attack prevention via configurable size limits
- Sensitive data exposure prevention via log truncation

The description will be used to generate the site documentation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@lukaszlenart lukaszlenart marked this pull request as draft November 28, 2025 07:50
@lukaszlenart lukaszlenart marked this pull request as ready for review November 28, 2025 08:14
@lukaszlenart
Copy link
Member Author

//cc: @sepe81

Remove singleLine parameter and complex whitespace normalization logic.
Revert to simple original compression: trim and remove whitespace between tags.

Changes:
- Remove singleLine field and setter from Compress and CompressTag
- Simplify compressWhitespace() to use single regex: >\\s+<
- Update documentation to remove singleLine attribute
- Update all tests to reflect simple compression behavior
- Maintain all security features (maxSize, log truncation, ReDoS protection)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@lukaszlenart lukaszlenart force-pushed the feature/WW-5256-freemarker-compress branch from 5c3a6b2 to 9e4f099 Compare November 28, 2025 08:19
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant