- Force US Locale for two tests that use date strings of the form
MM/DD/CCYY.
- When the tests/build are run in an environment with a non-US Locale
and newer JDKs the tests may fail due to inability to parse the US date
format.
Note: Was noticed on Windows 10 with JDK11, but could affect other
environments when run in a non-US Locale.
- Tests were using "text/html" which is not a valid character encoding.
No impact currently, but the tests could fail in the future if this is not
corrected. If the code is re-used elsewhere for a test of an action a
valid encoding will be needed.
- Switch to a predefined constant CharSet to get the string instead.
* Disable struts.ognl.expressionMaxLength by default for Struts 2.5.x.
- Commented out struts.ognl.expressionMaxLength line in default.properties
and provided in-place comments about its usage.
- Changed OgnlValueStack.handleOgnlException() methods to output error
instead of warn for failures to evaluate expressions due to security
constraints.
- Updated existing unit tests to compensate for change in default
behaviour.
- Added a unit test to confirm default behaviour for
struts.ognl.expressionMaxLength is disabled.
* Updated commit for disable struts.ognl.expressionMaxLength by default for
Struts 2.5.x
- Additional unit test requested by Y. Zamani for code coverage.
- Corrected accidental use of wrong (static) toString method in one test.
- Addition of a minimum struts.ognl.expressionMaxLength value permitted
by Struts 2 (128). Any value smaller than that is likely to be a
configuration error and if a user really wishes to force it they may go to
OGNL directly to do so.
* Updated commit for disable struts.ognl.expressionMaxLength by default for
Struts 2.5.x
- Removed minimum struts.ognl.expressionMaxLength (restored to previous
behaviour) as requested by Y. Zamani and L. Lenart.
- Updated unit tests to compensate for the above change.
- Changed log output from warn to error in applyExpressionMaxLength() on
exception since it will likely be considered a fatal condition.
- added some additional exclusions in struts-default.xml.
- added log warning that specifies the value of maxLength involved if
applyExpressionMaxLength(maxLength) fails.
- added null guards to two handleOgnlException() methods that could
result in an NPE with #371 changes (a null OgnlException parameter
was permissible previously, correct or not).
L. Lenart).
Added comment to explain why the log output avoids a stacktrace (due to
exceptions being re-thrown).
Updated existing ServletRedirectResultTest to supply tests that exercise
the new code paths and demonstrate expected logging.
Changed the log outputs to output full stacktraces (as suggested by
A. Mashchenko and L. Lenart).
Updated existing DefaultStaticContentLoaderTest and created a new
DefaultDispatcherErrorHandlerTest to supply tests that exercise the new
code paths and demonstrate expected logging.
Supply log warning when an IOException or IllegalStateException occurs to
better allow developers to track the failed redirect location and status
details. The exceptions are re-thrown to ensure existing flow-control
behaviour is preserved.
When getWriter() is called, utilize a finally block to ensure close is
called.
suggestion by A. Mashchenko and L. Lenart)
Changed the log outputs in this PR from info level to warn level (as per
suggestion by L. Lenart).
Note: The info level was originally chosen to make it easier to filter out
in the very unlikely case of log flood.
DefaultStaticContentLoader.
Provide informational logging for the processing of the two dispatcher
classes when an http sendError fails for the two known failure types
(IOException, IllegalStateException).
In both circumstances it is beneficial to have the developer aware of the
failures via the logs. These are not events that should be happening on a
regular basis, so there is little risk of a log flood.
DefaultStaticContentLoader didn't catch either exception type previously,
so changing it to make handling the same as DefaultDispatcherErrorHandler.
For DefaultDispatcherErrorHandler the IOException was caught with no
notice of failure previously. Now there will be an info level log output.
Previously the IllegalStateException was not caught, which resulted in the
unrecoverable exception being thrown up to the calling thread, usually
resulting in an ugly stacktrace to stdout/stderr. Now there will be an
info level log output instead.
If devMode is true, the info log outputs will include the exception
parameter to the log, so a stacktrace can be viewed for more details. If
devMode is false (production mode), then only the exception's tostring()
output will be produced.
- Provide cache clearing methods for OgnlUtil (expression cache, BeanInfo
cache).
- Provide methods to check the cache sizes (entry number for expression
cache, BeanInfo cache).
- Provide static method to clear the OgnlRuntime cache (convenience
method).
Moves checking OgnlValueStack.THROW_EXCEPTION_ON_FAILURE outside loop because it shouldn't throw exception on first failure while is trying all root objects.
Returns on first successful call because it's not rational and is confusing user to skip when user method successfully returns null as an actual result.
Fixes WW-4999 via honoring (devMode && logMissingProperties) for OgnlValueStack.THROW_EXCEPTION_ON_FAILURE and REPORT_ERRORS_ON_NO_PROP.
* include ref in path for StrutsApplicationResource as WW-5011 workaround
* add license to newly added xml files in previous commit
* WW-5011 include ref in path via .toURI().getPath()
* WW-5011 check protocol and not throw exception due to lazy file existence
* decrease log file size to pass travis build
- Made "constant" RELOADED static to save an initialization every time.
- Updated clearBundle(final String bundleName) method comment as it
seemed inaccurate, added debug log output when called.
- Introduced protected clearBundle(final String bundleName, Locale locale)
method for use by descendants, with debug log output when called.
- Introduced protected clearMissingBundlesCache() method for use by
descendants, with debug log when called.
- Correct missing verification in buildAllowedMethods()/loadGlobalAllowedMethods() that the nodes are
of type Node.TEXT_NODE (as buildResults() does).
- Made two class fields final, as suggested by IDE.
Note: Unlike some similar constructs in other header fields, media
type parameters do not allow whitespace (even "bad" whitespace)
around the "=" character.
Reference: https://tools.ietf.org/html/rfc7231#section-3.1.1.1
See also: WW-4958
* Proposed fix for WW-5029 for the 2.5.x branch:
- NOTE: If the PR is accepted please credit Maxime Clement for this change as they found
the issue, identified the probable cause/related details and opened the JIRA.
- Updated XWorkConfigurationProvider buildAllowedMethods(), loadGlobalAllowedMethods() so that
they now handle situations when a SAX parser produces multiple elements to represent the tag
body value.
- No changes to unit tests.
* Update commit to fix weakness identified by Maxime Clement:
- Implementation should now properly concatenate the node children values together (as a single unified string)
in both buildAllowedMethods(), loadGlobalAllowedMethods() - before generating the method Set to be added.
- Made some eligible variables final.
* Update commit to provide new unit tests:
- Added unit tests to confirm the fixes for buildAllowedMethods(), loadGlobalAllowedMethods()
- Added Mock DOM classes sufficient for these tests.
- Added unit tests to cover buildResults() and loadGlobalResults().
Proposed fix for WW-5028 for the 2.5.x branch:
- Disable printing stacktrace on exceptions by the Dispatcher by default.
- Printing stacktrace on exception is only enabled with devMode set to true, as suggested by L. Lenart.
- Now prints stacktrace on exception using LOG, as suggested by A. Mashchenko and the the JIRA reporter.
Log level set to debug as recommended by Y. Zamani.
- Added two additional unit tests for Dispatcher devMode and handleException states.
- NOTE: If the PR is accepted please credit Robert Hollencamp (Github @rhollencamp) for this change
as he found the issue, proposed a solution for 2.6 (master), and opened the JIRA.
- Updated HttpParameters, ActionMappingParametersInterceptor to prevent multi-level Parameter wrapping from occuring.
- Added a new ActionMappingParametersInterceptorTest to verify the fix.
- Fixes error 500 processing failures for double-submit results with TokenSessionStoreInterceptor processing
- Fix to InvocationSessionStore, new unit test confirming fix in InvocationSessionStoreTest
- Minor whitespace fix to TokenSessionStoreInterceptor
- This backport resulted from a review inspired/suggested by Y. Zamani in discussions for PR#334.
- Backports fix of error in testNullMethod().
- Backports applicable static access tests (static method access only), cleanup of unused imports.
- As with 2.6, it uses Y. Zamani's improved/enhanced reload mechanism.
* Fix for NPE issue discovered in WW-5004.
- Guard fix for a NPE that can arise under certain conditions, identified by A. Mashchenko.
* Fix for NPE issue discovered in WW-5004 (amended commit).
- Guard fix for a NPE that can arise under certain conditions, identified by A. Mashchenko.
- Requires the following elements to implement a fuller fix:
- Back-port relevant guard logic in ProxyUtil from master into 2.5.x to deal with the NPE.
- Update SecurityMemberAccess to block access to static fields.
- Upgrade to OGNL 3.1.22 (re-enables access to public static fields w/out access checks).
- Add unit test to confirm proper functionality of the fix.
- Correct missing entry in 4 test configuration XML files (needed for new unit test).
- Replaced literal injection parameter name for setStaticFieldAccessLevel in OgnlValueStackFactory with the appropriate constant.
Note: Even though a constant was defined in StrutsConstants, the value for the injection name in all places is the XWorkConstants.
It has to remain the same to avoid breaking anything.
- Made a private ConcurrentMap reference final, made initial sets immutable (consistency).
- Made sets for Accepted and Excluded patterns checkers immutable in 2 modules (consistency).
- Added @Override annotations missing from a few methods in 2 modules.
- Updated the 3 relevant unit tests to verify immutable states of various sets.