Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Pull - #2

Open
prateek200787 wants to merge 76 commits into
apache:STRUTS_1_2_BRANCHfrom
kawasima:STRUTS_1_2_BRANCH
Open

prateek200787 wants to merge 76 commits into
apache:STRUTS_1_2_BRANCHfrom
kawasima:STRUTS_1_2_BRANCH

Conversation

@prateek200787

Copy link
Copy Markdown

No description provided.

kawasima and others added 30 commits May 13, 2015 10:23
- Implement tests for OptionTag to validate XSS protection and HTML escaping.
- Create tests for ForwardTag to ensure proper forward handling and error management.
- Add tests for MatchTag and NotMatchTag to verify matching logic against request parameters and attributes.
- Introduce tests for NotEmptyTag to check for non-empty conditions on various data types.
- Develop tests for ModuleUtils to validate module configuration retrieval and selection.
- Add tests for ResponseUtils to ensure proper HTML character escaping and URL encoding.
This commit introduces a new XML file, validator-rules.xml, which contains the default pluggable validator definitions for Struts. The file includes various validation rules such as required fields, length checks, data type validations, and more. It also provides associated error messages that can be referenced in the ApplicationResources.properties file. This setup is essential for integrating the Struts Validator into the application.
…revent path traversal

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix GHSA-xgrq-qjm7-p99v: validate page parameter in SwitchAction to p…
…revent XSS

Apply ResponseUtils.filter() to message content in ErrorsTag.doStartTag()
before appending to output buffer. Previously, non-resource ActionMessage
keys and resource message arguments were written raw, allowing reflected
XSS (CVE-2012-1007).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rt handlers to prevent memory exhaustion

Add a configurable maxTextFieldSize property (default 256KB) to
ControllerConfig. CommonsMultipartRequestHandler.addTextParameter()
now checks item.getSize() against the limit and skips oversized
fields. MultipartIterator.createTextMultipartElement() tracks bytes
read and drains the stream without storing data when the limit is
exceeded; getNextElement() recurses past skipped fields so subsequent
normal-sized fields are still returned.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Enforce per-text-field size limit in multipart handlers
…eter population to prevent validator bypass

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix GHSA-cr42-9px3-5v7x: suppress validatorResults from request parameter population
… to prevent path traversal

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix GHSA-6gxc-rr3q-63w6: path traversal via Tiles LOCALE_KEY
… output to prevent CRLF log injection

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix GHSA-r7xj-rhwv-rpq5: CRLF log injection in LookupDispatchAction
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
kawasima and others added 30 commits November 25, 2026 16:14
…rMap

ServletApiLinkChecker (extracted from TestServletApiCompatibility)
resolves every Servlet/JSP type named in the constant pool, both class
constants and types in descriptors and signatures. Class constants used
only in method bodies (class literals, casts, instanceof) were no longer
checked. TestServletApiLinkChecker pins each check with fixture classes
and a class loader that hides one API type.

The jakarta MultipartRequestWrapper.getParameterMap() reads the wrapped
request through getParameterNames() and getParameterValues(), like the
javax class, so request wrappers that override only those methods are
honoured. Tests pin this and the setRequest() behaviour: a replacement
applies to every delegated method, and a rejected one leaves the
delegate unchanged.

The integration test sets HTTP connect and request timeouts, and
failsafe and invoker have process timeouts.

Refs #8

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Build a jakarta-classifier JAR with Eclipse Transformer
1.2.9-forever-3 set disallow-doctype-decl on every Digester to stop XXE
(GHSA-h36r-7whm-p5hf). That rejected the standard DOCTYPE of web.xml,
struts-config.xml and Tiles definition files, so ActionServlet failed
to start for almost every Struts 1 application.

DigesterSecurity now restricts what the parser may read instead of
which documents it accepts. It installs an EntityResolver that returns
a DTD or entity only if trusted code registered it with
Digester.register() or set its own EntityResolver, and fails the parse
for anything else, so the parser never opens a system identifier taken
from the document. Registrations are read through
Digester.resolveEntity(publicId, null), which never falls back to the
system identifier, so DTDs that subclasses or applications register
keep working and Digester.getPublicId() is still set.

The settings are applied to the XMLReader right before parsing, after
the Digester is configured. forever-3 called Digester.setFeature()
first, which created the SAXParserFactory with validating and
namespaceAware still false; later setValidating(true) had no effect,
so struts-config.xml and Tiles files were not validated. Applying the
settings to the reader also covers a Digester built from an XMLReader.

The external entity features stay required, as in forever-3. Secure
processing, XInclude and the JAXP accessExternal* properties are set
where the parser supports them, so an older Xerces in WEB-INF/lib still
works.

DigestingPlugIn also secures the Digester that parses its digester
rules file. In forever-3 that parse fetched an unregistered DTD.

A DOCTYPE that names an unregistered DTD now fails to parse. Up to
forever-2 the parser downloaded it. README describes this.

TestTilesPlugin runs again, and the integration test uses a
struts-config.xml with a DOCTYPE and the default validating=true.

Fixes #3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of the previous commit found that the policy was attached to
Digester instances that Struts code created and remembered to secure,
not to the parsing itself. Parsers created elsewhere were left out,
settings that a parser refused were skipped, and a caller that forgot
DigesterSecurity.secure() parsed without it. The same cause left two
more paths open: ValidatorPlugIn, whose Commons Validator parser reads
any external DTD or entity, and rules files included from a
DigestingPlugIn rules file.

DigesterSecurity now checks conditions instead of calling setters, and
refuses to parse when one does not hold:

- external general and parameter entities are off;
- external DTDs and entities come only from registrations or an
  EntityResolver the application set; the documented trust boundary
  is that these are the application's permission and its I/O;
- entity expansion is limited, through secure processing or, on
  Xerces versions without it such as 2.6.2, the Xerces security
  manager. Allowing DOCTYPE again had made billion-laughs documents
  possible, and Xerces 2.6.2 has no limit of its own;
- XInclude is off, or the parser does not implement it.

A document that declares an external general entity now fails to
parse. External entities are not expanded, and forever-3 silently
dropped such references, so a struts-config.xml split with &name;
loaded with parts missing. The declaration is rejected because
Xerces 2.6.2 drops the reference without calling skippedEntity().

SecureDigester applies the policy in getXMLReader(), which every
Digester.parse() method uses, so it holds whoever calls parse(),
including subclasses that parse with initConfigDigester() directly.
Struts creates all its Digesters as SecureDigester and still secures
application-supplied ones before parsing.

SecureDigesterLoader replaces DigesterLoader. It swaps the Commons
Digester include rule for one that behaves the same but parses with a
SecureDigester at every include depth, and fails if that rule is not
found.

ValidatorResourcesLoader loads validation files as
new ValidatorResources(InputStream[]) does in Commons Validator 1.7,
through public API, with a SecureDigester. A test compares the two
and checks the DTD list against Commons Validator.

Tests check that a registered DTD is actually read (via a default
attribute), run the policy against Xerces 2.6.2 loaded by its own
class loader, and fail when any of these fixes is reverted.

Refs #3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The second review found that some checks confirmed that a mechanism was
switched on rather than that the property it should give held. Secure
processing reads back as true while an explicit entityExpansionLimit of
0 (for example -Djdk.xml.entityExpansionLimit=0) keeps expansion
unlimited, and a Xerces SecurityManager was accepted without looking at
its limit. Reviewing every check for the same pattern found two more:
the declaration handler fell back to a skippedEntity() override that
plain Digesters do not have, and no parser limit bounded the expanded
size of a document on Apache Xerces, which counts expansions only.

Entity expansion is now bounded on every parser by two limits that are
read back. The parser's expansion limit must be between 1 and
MAX_ENTITY_EXPANSIONS (10,000); a lower limit is kept, a higher or
missing one is lowered, through the JDK property or by installing a new
Xerces SecurityManager (an application's manager may be shared, so it is
not changed). The declaration handler, now required, rejects an
internal entity whose replacement text exceeds MAX_ENTITY_LENGTH (5,000
characters). Each expansion produces at most that much text itself, so
a document expands to at most 50,000,000 characters on any parser.

The skippedEntity() override is removed; external entity declarations
are rejected through the required declaration handler on all
Digesters. DigesterSecurity.secure() does nothing for a SecureDigester,
which applies the policy when it parses, and initServlet() no longer
calls it.

Tests for XInclude and XML Schema now pair a parser that does fetch the
external document without the policy with the same parser under the
policy. New tests cover a limit of 0 with secure processing on, a kept
lower limit, a replaced Xerces SecurityManager, entity length at and
over the limit, expansion inside attribute values, an unreferenced
external entity declaration and a parser without declaration events.
Reverting each change makes a test fail.

Refs #3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The third review found two ways around the parsing policy. Both come
from conditions the policy relied on without establishing them.

A parser set to continue after fatal errors reports an exceeded entity
expansion limit and goes on, because Digester.fatalError() only logs
and passes the error on. Every limit the parser enforces itself (the
expansion limit, the JDK size limits, the JAXP access restrictions)
relied on the parser stopping. SecureDigester.fatalError() now
rethrows after passing the error on, and DigesterSecurity.secure()
wraps the error handler of other Digesters so that it does the same.
Parsing stops whatever the parser's setting; the resolver and the
declaration handler already stop it by throwing.

Applying the policy could relax limits: turning on secure processing
makes Apache Xerces 2.7+ install a new SecurityManager, which dropped a
stricter expansion limit, and a replaced manager kept none of the old
manager's other limits (maxOccurNodeLimit). Every setting the policy
makes was checked; these were the only ones that could relax anything.
Secure processing is no longer set: the JDK parser applies its limits
without it and the policy sets the expansion limit itself. A Xerces
manager is now replaced only when its expansion limit is unusable, and
the replacement copies every int limit of the old one and lowers only
the expansion limit; the copy is read back.

The Xerces checks run against 2.6.2 and 2.12.2, which has secure
processing. Both JARs are copied by maven-dependency-plugin, declared
right after the compiler plugin so that the jakarta profile's
executions keep their order. New tests: a JDK parser set to continue
after fatal errors parses past its limit without the policy and stops
under it (for a plain Digester and a SecureDigester), stricter JDK and
Xerces limits are kept, and a replaced manager keeps maxOccurNodeLimit.
Reverting each change makes a test fail.

Refs #3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fourth review found that a Xerces SecurityManager with an expansion
limit of 0 was replaced by one allowing 10,000 expansions. The policy
read the Xerces limit with the JDK's meaning, where 0 or less means no
limit. Xerces compares the count before incrementing it: a limit of v
allows v + 1 expansions, 0 allows one and a negative limit none; only
the absence of a manager means no limit. Measured on Xerces 2.6.2 and
2.12.2 and on the JDK, where a positive limit v allows exactly v.

Every place where the policy interprets a value read from the parser
was checked for the same mistake. Three more were found: a Xerces limit
that could not be read was returned as 0 and so treated as unlimited; a
JDK limit that is not a number was treated as unlimited and overwritten,
though it might be stricter; and the Xerces manager Struts installs was
set to 10,000 and so allowed 10,001 expansions, not the documented
10,000. Copying the other manager limits, reading back features and
checking the declaration handler take values as they are and were left
as they were.

Each parser's limit is now converted to the number of expansions the
parser allows (jdkAllowed, xercesAllowed) and only then compared with
MAX_ENTITY_EXPANSIONS. A limit that cannot be read is not overwritten;
parsing is refused. The Xerces manager Struts installs uses
MAX_ENTITY_EXPANSIONS - 1.

New tests: with the policy, an unlimited JDK parser and a Xerces parser
without a manager accept exactly 10,000 expansions and reject 10,001; a
Xerces manager with limit 0 is kept and rejects two expansions; a
manager allowing 100,000 is replaced keeping maxOccurNodeLimit; an
unreadable JDK limit or Xerces manager is refused, also when
overwriting the JDK limit would succeed. Reverting each change makes a
test fail.

Refs #3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Applications that replaced only the Struts JAR may still have the
Commons Validator 1.1.4 and Commons Digester 1.6 that Struts 1.2.9
shipped in WEB-INF/lib. forever-3 worked with them. With 1.1.4,
ValidatorPlugIn now failed to start: ValidatorResourcesLoader copied the
loading code of Commons Validator 1.7, whose arg0-arg3 rules conflict
with the rules that 1.1.4 has in its digester-rules.xml
(ClassCastException).

The cause was copying version-specific internals of a library whose
version the application chooses. ValidatorResourcesLoader now reads
each validation file into memory, parses it with a SecureDigester that
registers the Commons Validator DTDs present on the class path, and
gives the same bytes to new ValidatorResources(InputStream[]) of
whatever version is deployed. The second parse reads nothing the first
did not: the DTD is one that Commons Validator registers (versions
1.1.4 to 1.7 ship and register the same DTDs, checked for each), the
same bytes expand the same entities, and the file declares no external
entity.

That last condition required closing a gap in the policy: an external
parameter entity was declared and silently skipped, which Commons
Validator's own parser would have fetched, and which elsewhere dropped
part of a DTD without notice. The declaration handler now rejects
external parameter entities as well; no registered DTD declares one.

The policy also looks for the security manager of the Xerces inside
JDK 5 to 7 (com.sun.org.apache.xerces.internal.util.SecurityManager),
which have no other entity expansion limit before 7u40; only the Apache
Xerces class was tried before, so parsing would have been refused there.
JDK 5 to 7 were not available to run this.

TestOldCommonsLibraries runs the XML parsing test classes again in a
class loader with Commons Digester 1.6 and Commons Validator 1.1.4 in
place of the declared versions; it fails with the previous
ValidatorResourcesLoader. TestValidatorResourcesLoader pairs a file
with an external parameter entity that Commons Validator alone fetches
with the same file through the loader, and checks the loader's DTD
registrations against the Commons Validator on the class path. The
policy was also run on a JDK 8 runtime.

Refs #3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Accept DOCTYPE declarations and read only registered DTDs
1.2.9-forever-3 made BaseHandlerTag.prepareAttribute() pass every value
through TagUtils.filter(), which also escapes &. The values it receives
have always been HTML, not data: TagUtils.computeURL() separates URL
parameters with &amp;, RadioTag and MultiboxTag escape their value with
filter() before passing it, and event handlers, title and alt are written
by page authors or message resources. Escaping & again changed what the
browser reads: <html:link> with several parameters sent "amp;from"
instead of "from", radio and multibox values were submitted as
"A&amp;B", and character references in handlers and titles showed
literally.

The other forever-3 escaping changes were checked for the same mistake.
OptionTag (d5190ef) escapes its value and label with filter() by
default, although they are HTML too (body content, a message resource
or the value attribute), so labels with &nbsp; or &eacute; showed the
reference. The JavascriptValidatorTag change (f8cb68a) escapes for
JavaScript inside a script element and is not affected.

LegacyMarkup.escape() escapes ", ', < and > and keeps &. The browser
decodes each of these back to the same character, so it reads the value
of 1.2.9-forever-2, while a value can no longer end its attribute or
start an element, which was the point of the forever-3 change.
prepareAttribute() and OptionTag (with filter="true", the default) use
it; filter="false" still writes the label and value as given. The
signatures of prepareAttribute() and OptionTag are unchanged, so custom
tags that call or override prepareAttribute() keep working.

Escaping does not make data safe inside JavaScript, a URL or CSS; the
Javadoc of prepareAttribute() and the TestBaseHandlerTagXss description
now say so instead of claiming XSS protection.

Fixes #4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The section described the XML parsing policy of issue #3. That is
documented in the Javadoc of DigesterSecurity and belongs in the release
notes, not in the README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of the previous commit found that OptionTag wrote its value as
HTML while SelectTag.isMatched() compares the same value with the form
property as data: a value written as "a&amp;b" was submitted as "a&b"
and the option was not selected again when the form was shown.

The cause is one value serving as both HTML output and data that the
server compares. Every tag whose value is submitted was checked.
CheckboxTag has the same problem: isChecked() compares its value with
the form property, but the value went through prepareAttribute() as
HTML. RadioTag and MultiboxTag already escape their value with
TagUtils.filter() before passing it, and TextTag, HiddenTag and the
options tags escape completely. Submit, button, reset and cancel use
their value both as the label shown and as the value submitted, which
LookupDispatchAction compares with message text; one string cannot be
both, so they keep the 1.2.9 behaviour (HTML).

OptionTag (filter="true") and CheckboxTag now escape their value with
TagUtils.filter(), which is also what 1.2.9-forever-3 wrote, so the
submitted value is the value the tag compares. The option label stays
HTML and keeps its character references. The Javadoc of OptionTag, the
TLD description of its filter attribute and TestOptionTag explain the
difference to <html:options>, whose labels come from beans.

LegacyMarkup and prepareAttribute() no longer claim more than they do:
LegacyMarkup is not an encoder for data, and a raw & in its input stays
raw, so the result is well-formed XHTML only if the input was.

The tests decode attributes as a browser does and compare what the
browser reads: all parameters of <html:link> (several parameters, an
existing query, paramId with a transaction token), <html:frame> and
<html:img>; radio, multibox and checkbox values that look like
character references ("A&amp;B") are submitted as given; an option is
submitted and selected with the same value. Reverting OptionTag or
CheckboxTag to the previous commit makes a test fail.

Refs #4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An option without body text or a key shows its value as the label. The
value is data, so the label now escapes it completely instead of as HTML;
whether the label came from the value is recorded by text(), not guessed
from the string. The name attribute of form fields is the request
parameter a property is populated from, so it is escaped as data too.

Document that event handler code must be escaped with filter() after
escaping data for JavaScript, narrow the test decoder to the references
the tags write, and count repeated URL parameters in assertUrl.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Escape only what can end an attribute in tag output
Issue #5 reported that 1.2.9-forever-3 escaped the body of <html:option>
twice, so &nbsp; and the output of <bean:write> showed as entities. The
fix landed with issue #4 (LegacyMarkup.escape() for the label), but the
tests covered body text injected into the tag only.

Add tests for the two paths the issue is about. A label looked up by key
keeps its character references, as <bean:message> writes message
resources as HTML (the examples app uses &lt;Select One&gt; this way),
and still cannot add elements to the page. A <bean:write> nested in the
body goes through doAfterBody() and is shown escaped once. A blank
option written as &nbsp; stays blank.

Fixes #5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Body

Review of the previous commit found that testLabel_FromKey_EscapesMarkup
passed with the escaping removed. label() took the text up to the first
"</option>" and decoded it, so "</select><script>" written raw and the
same text escaped gave the same label. The browser ends the text at the
first "<". label() now ends the start tag at the first ">" outside a
quoted value and the text at the next "<", and fails unless that "<"
starts "</option>". It was the only test helper that reads text content;
attribute() already ends at the closing quote.

The body tests set the label with a subclass that overrode doStartTag(),
because MockPageContext.pushBody() returned null and there was no body
content to write into. They never ran doAfterBody(), which trims the body
and ignores a blank one. pushBody() now returns a MockBodyContent and
makes it the page writer until popBody(), as a container does; nothing
else called it. Every body test writes its body there, and the subclass
is removed. Tests for trimming, a blank body and a tag instance used
twice are added.

With LegacyMarkup.escape() made to return its input, three tests fail;
with the label escaped by TagUtils.filter() as in 1.2.9-forever-3, six
fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Test html:option labels from a key and from a nested bean:write
Since 1.2.9-forever-2 ErrorsTag escaped the whole formatted message, so
markup written in the message resources, such as
"Login failed for user <strong>{0}</strong>.", was shown as text.
The template comes from the application; only the arguments may hold
user input.

HtmlMessageFormatter formats the message with
MessageFormat.formatToCharacterIterator() and escapes each run marked
MessageFormat.Field.ARGUMENT. The escaping applies to the formatted
text, so a Number, a Date or any object whose toString() returns markup
is covered, and number, date and choice subformats work as before. The
message is formatted once. The MessageFormat is built as
MessageResources.getMessage(Locale, String, Object[]) builds it: single
quotes doubled when isEscape() is true, setLocale() after construction.
Without arguments the template is written as it is, as
TagUtils.message() returns it.

This applies only when the resources are PropertyMessageResources
itself and isPresent() is true. A subclass or another implementation
may format messages its own way, and the "???key???" text for a missing
key holds the key, not a template; both are escaped whole as in
forever-2. Text chosen by a ChoiceFormat is marked as an argument as a
whole, so markup inside a choice is escaped.

Messages with resource="false" are still escaped whole. The tag
documentation states that the argument escaping is for HTML text only.

Test*.properties under src/test are now copied to the test classpath;
a wider pattern would let the old taglib/LocalStrings.properties there
shadow the one in src/share.

Fixes #6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of the previous commit found two output differences from
MessageResources.getMessage(Locale, String, Object[]): the pattern is
parsed on every call instead of once, and a null locale becomes the
current default instead of the one saved by the resources. Both come
from building the MessageFormat outside MessageResources, whose cache
and protected members cannot be reached from taglib.html without new
public API. The class Javadoc now lists every case where the output can
differ, and says to move the class next to MessageResources if another
tag, such as bean:message, needs it.

Tests added:
- A template that starts and ends with "???" is taken for a missing key
  by isPresent() and escaped whole; this pins the accepted direction of
  the heuristic.
- ErrorsTag writes the header, footer, prefix and suffix around each
  message, with a resource message and a literal one, compared whole.

The class Javadoc of TestErrorsTag and TestSwitchAction said the tests
would fail until the fix; both fixes have landed, so they now describe
the required behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"<" separates choices in a ChoiceFormat pattern. The unquoted pattern
{0,choice,0#<i>none</i>|1#<i>one</i>} throws IllegalArgumentException
on JDK 8; JDK 25 and 27 accept it, and the suite had only been run on
JDK 27. The pattern now quotes the markup, and the test uses resources
with escape=false so that MessageResources does not double the quotes.

Every test class now passes on a JDK 8 runtime as well as in
mvn clean verify on JDK 27.

The paragraph in HtmlMessageFormatter about moving the class later is
removed; the Javadoc describes the class as it is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Javadoc and comments state what the code does, in the style of the
surrounding Struts sources: <code> instead of {@code}, no release or
issue history, and no design rationale. ErrorsTag keeps its existing
layout and wraps the locale lookup like the other calls in doStartTag().
The html:errors documentation is reworded to match the rest of
struts-html.xml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Write html:errors templates as HTML and escape only their arguments
Commons Validator 1.5 removed the JavaScript files that the default
validator-rules.xml names (by jsFunction or by the rule name). Since
the upgrade to 1.7, ValidatorAction.getJavascript() returns null for
every default rule, so JavascriptValidatorTag drops them all and the
generated validate<Form>() function always returns true.

The Struts JAR now contains the 14 scripts of Commons Validator 1.1.4,
the version Struts 1.2.9 shipped, unchanged and under the same
resource names. ValidatorAction still loads them from the class path,
so existing validator-rules.xml files work as before. Applications
that keep commons-validator-1.1.4.jar in WEB-INF/lib see the same
script whichever JAR the class loader finds first.

Fixes #7

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ship the Commons Validator 1.1.4 scripts for html:javascript
…RequestWrapper

The default JAR's MultipartRequestWrapper implements HttpServletRequest
directly and is compiled against Servlet 2.2. On Servlet 3.0+ containers
every method added since then (getServletContext(), getDispatcherType(),
changeSessionId(), ...) throws AbstractMethodError on multipart
requests, and the Servlet 4.0 default methods fall back to the interface
instead of the container's request.

The wrapper that the jakarta JAR already used moves from src/jakarta to
src/servlet3, written against javax.servlet and compiled against
Servlet 3.0 with Ant's javac, so that Servlet 3.0 comes before 2.2 on
the class path. It replaces the Servlet 2.2 class in a new
struts-<version>-servlet3.jar and, transformed, in the jakarta JAR.
The default JAR is unchanged.

The jakarta profile now also runs the unit tests against the servlet3
classes on Servlet 4.0, TestServletApiCompatibility on Servlet 3.0 and
3.1, and src/it/servlet3-tomcat on Tomcat 9.0.

Fixes #10

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TestMultipartRequestWrapper decided from the superclass of the class
under test whether setRequest must exist, so a servlet3 or jakarta
class that lost its superclass skipped those tests instead of failing.
Each surefire execution now passes struts.build (javax, servlet3 or
jakarta), and the tests check the class shape of that build.

Every other method of the HttpServletRequest on the class path is now
checked to pass arguments, result and exception through, including the
Servlet 4.0 default methods. The javax build's reflective methods,
which log an exception and return null, false or 0 as in Struts 1.2.9,
and the servlet3 build's getRealPath and isRequestedSessionIdFromUrl
are pinned by their own tests.

The servlet3 and jakarta JARs replace the default JAR, but nothing
stopped two Struts JARs from being deployed together. ActionServlet
logs a warning at startup when its class is found in more than one
location, and both integration tests require exactly one Struts JAR.

README and CLAUDE.md no longer present class file versions as runtime
requirements: the declared dependencies need Java 8, and Struts needs
Commons BeanUtils 1.9.2 or later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ActionServlet.init() turns any exception into UnavailableException, so
a SecurityException from ClassLoader.getResources() in the new check
would have stopped the servlet. duplicateLocations() now returns null
when the class loader cannot be searched, and counts a location that
the class loader returns twice only once.

The delegation test now also throws each checked exception that a
method declares. setCharacterEncoding() logs UnsupportedEncodingException
in every build; README says so, and lists setCharacterEncoding() among
the methods that the default JAR calls through reflection. Tests accept
only javax, servlet3 and jakarta as struts.build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ship a servlet3 JAR whose MultipartRequestWrapper extends HttpServletRequestWrapper
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants