Commit Graph
2421 Commits
Author SHA1 Message Date
Mathieu Lirzin d0a1dde34e Improved: Turn ‘MiscTests’ into a unit test class
(OFBIZ-11067)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859982 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 14:25:28 +00:00
Mathieu Lirzin 36d284097e Turn ‘IndentingWriterTests’ into a unit test class
(OFBIZ-11067)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859979 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 14:23:12 +00:00
Mathieu Lirzin 10a8ad3097 Improved: Turn ‘GenericMapTest’ into a unit test class
(OFBIZ-11067)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859978 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 14:20:53 +00:00
Mathieu Lirzin 1103a2a3e1 Improved: Turn ‘DateTimeTests’ into a unit test class
(OFBIZ-11067)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859977 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 14:18:19 +00:00
Mathieu Lirzin 2a4a9bad13 Improved: Turn ‘ComparableRangeTests’ into a unit test class
(OFBIZ-11067)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859976 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 14:15:40 +00:00
Mathieu Lirzin 0dede26601 Improved: Turn ‘UtilPropertiesTests’ into a unit test class
(OFBIZ-11067)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859975 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 14:12:37 +00:00
Jacques Le Roux 402db94e61 Fixed: Duplicate entries in paramWithSuffix
(OFBIZ-11056)

when using string-list-suffix attribute for service definition, invoke method 
(from associated event handler) will try to parse parameters from both request 
variable and rawParameterMap which was also built from request. 
So we end up with duplicates in resulting list.

This behaviour seems to be introduced with OFBIZ-5048.


Thanks: Samuel Trégouët for report and fix 

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859972 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 14:08:48 +00:00
Jacques Le Roux c26b16a5ee Fixed: Services allow arbitrary HTML for parameters with allow-html set to "safe"
(OFBIZ-5254)

The testCreateNewRequest was failing due to escaped single quotes in related
data in OrderTypeData.xml:
subject="OFBiz - Your Request is received: '${custRequestName}' #CR${custRequestId}"

This was a peculiar case that could be generalised to all escapable characters.
The general solution is to compare the original value with the filtered value 
unescaped in UtilCodec::checkStringForHtmlSafe.
BTW, weirdly enough StringEscapeUtils::escapeHtml4 does not escape single quote.

Another weirdness is the test was passing with plugins data loaded. This is due
to duplicated demo data in scrumTypeData.xml (which is actually not only type
data, as ever the scrum component is a mess, that's not new and always wonder
if we should not get rid of it!)

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859968 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 13:25:34 +00:00
Mathieu Lirzin 410a67a3dc Improved: Turn ‘StringUtilTests’ into a unit test class
(OFBIZ-11014)

Since there is no dependency on the delegator and dispatcher for those
tests, it is better to run them as unit tests instead of integration
tests.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859937 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 09:38:42 +00:00
Mathieu Lirzin 008fd8ded4 Improved: Remove unused ‘StringUtil#appendTo’ methods
(OFBIZ-11014)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859934 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 09:28:36 +00:00
Mathieu Lirzin 047340f8a5 Improved: Remove unused ‘StringUtil#collapseCharacter’
(OFBIZ-11014)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859932 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 09:27:09 +00:00
Mathieu Lirzin b601acc979 Improved: Remove unused ‘StringUtil#collapseSpaces’ method
(OFBIZ-11014)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859930 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 09:25:41 +00:00
Mathieu Lirzin 87a02f4ca7 Improved: Remove unused ‘StringUtil#collapseNewlines’ method
(OFBIZ-11014)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859929 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 09:24:37 +00:00
Mathieu Lirzin b24f702c77 Improved: Remove unused ‘StringUtil#removeNumeric’ method
(OFBIZ-11014)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859928 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 09:22:58 +00:00
Mathieu Lirzin ad9fc62be5 Improved: Remove unused ‘StringUtil#convertChar’ method
(OFBIZ-11014)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859927 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 09:21:53 +00:00
Mathieu Lirzin c79b0633ab Improved: Remove unused ‘StringUtil#mapToStr’ method
(OFBIZ-11014)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859926 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 09:21:06 +00:00
Mathieu Lirzin fd7eab1d30 Improved: Remove unused ‘StringUtil#strToMap’ overload
(OFBIZ-11014)

Make the other overload which is only used internally private.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859925 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 09:18:55 +00:00
Mathieu Lirzin b97461e47a Improved: Inline ‘StringUtil#quoteStrList’ method
(OFBIZ-11014)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859924 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 09:17:12 +00:00
Mathieu Lirzin 7bd53374ed Improved: Remove unused ‘StringUtil#split’ overload
(OFBIZ-11014)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859923 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 09:15:38 +00:00
Mathieu Lirzin d7aab2ff73 Improved: Remove unused ‘StringUtil#append’ method
(OFBIZ-11014)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859922 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 09:13:41 +00:00
Mathieu Lirzin d886fd1b1b Improved: Rewrite ‘StringUtil#join’ method
(OFBIZ-11014)

Use streams instead of low-level string builder.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859921 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 09:12:05 +00:00
Mathieu Lirzin ab2fcbcb4a Improved: Remove useless ‘StringUtil#join’ overload
(OFBIZ-11014)

‘List’ extends ‘Collection’ so there is no need to overload
‘StringUtil#join(Collection,String)’ with ‘StringUtil#join(List,String)’.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859920 13f79535-47bb-0310-9956-ffa450edef68
2019-05-25 09:10:12 +00:00
Jacques Le Roux 5a9b057f24 Improved: no functional change
Javadoc was unhappy: 
CustomPermissivePolicy.java:13: error: element not closed: blockquote


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859882 13f79535-47bb-0310-9956-ffa450edef68
2019-05-24 14:16:39 +00:00
Jacques Le Roux 2dadaacac8 Fixed: Services allow arbitrary HTML for parameters with allow-html set to "safe"
(OFBIZ-5254)

This was reopened after discussion at 
https://markmail.org/message/jnaitmwahjcjmdn5

This is a new solution which follows the work done with OFBIZ-6669 and OFBIZ-10187
Roughly said, it uses org.owasp.html.PolicyFactory and org.owasp.html.Sanitizers

Thanks: Christoph Neuroth for report

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859877 13f79535-47bb-0310-9956-ffa450edef68
2019-05-24 13:47:08 +00:00
Jacques Le Roux a0d9fba0d9 Fixed: OWASP sanitizer breaks proper rendering of HTML code
(OFBIZ-10187)

After a discussion with Dennis, I checked and the pattern ONSITE_URL would be 
useless without 

.allowAttributes("background").matching(ONSITE_URL)
.onElements("table")
.allowAttributes("background").matching(ONSITE_URL)
.onElements("td", "th", "tr")

So here they are

Thanks: Dennis Balkir for discussion

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859871 13f79535-47bb-0310-9956-ffa450edef68
2019-05-24 13:24:31 +00:00
Jacques Le Roux cce437fbdf Improved: no functional changes, only formatting
While working on OFBIZ-5254 after reopening it.

Uses the max width (120) makes things easier to read IMO

I also made a slight non functional change w/ seekSegmentTime in 
checkStringForHtmlStrictNone

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859297 13f79535-47bb-0310-9956-ffa450edef68
2019-05-15 16:18:01 +00:00
Jacques Le Roux 53f89ae595 Improved: no functional change, only formatting
While working on OFBIZ-5254 after reopening it.

Uses the max width (120) makes things easier to read IMO

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859295 13f79535-47bb-0310-9956-ffa450edef68
2019-05-15 15:39:03 +00:00
Mathieu Lirzin 3acf261b7f Fixed: Fix javadoc build for OpenJDK 11
(OFBIZ-10757)

This removes HTML5 deprecated stuff such as ‘<tt>’ elements, and
‘cellpadding’ table attributes which were breaking the ‘:javadoc’
Gradle task when using OpenJDK 11.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859123 13f79535-47bb-0310-9956-ffa450edef68
2019-05-11 20:36:45 +00:00
Mathieu Lirzin a0ac6ae331 Improved: Remove useless null check
(OFBIZ-10054)

Additionally the noisy ‘final’ modifiers on local variables have been
removed because local variables should be final by default and mutable
by exception.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859081 13f79535-47bb-0310-9956-ffa450edef68
2019-05-10 14:13:34 +00:00
Jacques Le Roux bea0b0e25f Fixed: OWASP sanitizer breaks proper rendering of HTML code
(OFBIZ-10187)

By default we now use a permissive sanitizer policy

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1858980 13f79535-47bb-0310-9956-ffa450edef68
2019-05-09 09:17:08 +00:00
Jacques Le Roux 822356ef14 Fixed: Product content management screen doesn't validate trusted users' input
(OFBIZ-10054)

Steps to recreate:
1) go to (authenticate with admin/ofbiz):
https://localhost:8443/catalog/control/EditProductContent?productId=WG-1111

2) set the content of the field labeled "Large Image" to:
non_existent.foo" onerror="alert('Hi!');

3) visit the url:
https://localhost:8443/ecommerce/control/product?product_id=WG-1111

A popup message will appear with the "Hi!".

jleroux: This is fixed by preventing any js event to be passed 

Thanks: Loris Nardo for report, Jacopo and Gregory for discussion

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1858965 13f79535-47bb-0310-9956-ffa450edef68
2019-05-09 06:05:05 +00:00
Mathieu Lirzin e8a656785a Improved: Remove useless ‘UtilMisc#makeSetWritable’ method
(OFBIZ-11015)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1858951 13f79535-47bb-0310-9956-ffa450edef68
2019-05-08 21:42:27 +00:00
Mathieu Lirzin 247367871c Improved: Rewrite ‘CustomPermissivePolicy#matchesEither’ static method
(OFBIZ-10187)

It now uses a lambda expression instead of an anonymous class.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1858933 13f79535-47bb-0310-9956-ffa450edef68
2019-05-08 17:09:25 +00:00
Mathieu Lirzin 9a8b403bb3 Improved: Add missing ‘synchronized’ modifier
(OFBIZ-11004)

Overriding a synchronized method with a non-synchronized one can
introduce potential runtime concurrency bugs. Since
‘ExtendedProperties#loadFromXML’ is overridding
‘Properties#loadFromXML’ which is synchronized, it is safer to mark it
as synchonized.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1858490 13f79535-47bb-0310-9956-ffa450edef68
2019-05-01 14:36:26 +00:00
Mathieu Lirzin ad645133b2 Improved: Remove unneeded generics in ‘MapContextTest’
(OFBIZ-10933)

This is done to remove a warning in OpenJDK 8 which doesn't seem to
handle ‘@safevarargs’ annotation properly when using generics.  This
warning was not present with OpenJDK 11.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1858483 13f79535-47bb-0310-9956-ffa450edef68
2019-05-01 12:55:51 +00:00
Mathieu Lirzin 2d01c1e142 Improved: Do not use ‘java.util’ backported classes
(OFBIZ-11003)

Probably due to some IDE auto-importing mistake, some classes meant as
backports of the ‘java.util.Arrays’ and ‘java.util.Collections’
classes were imported.  This make no sense since we are requiring
Java 8 which already provides those.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1858480 13f79535-47bb-0310-9956-ffa450edef68
2019-05-01 12:34:20 +00:00
Michael Brohl 52254f4435 Fixed: OWASP sanitizer breaks proper rendering of HTML code
(OFBIZ-10187)

This makes the sanitizing enabled/disabled by configuration and enhances
the functionality to support custom sanitizer policies. A reasonable 
example policy class is also included.

Thanks Dennis Balkir for reporting and providing the patch.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1858352 13f79535-47bb-0310-9956-ffa450edef68
2019-04-29 09:24:13 +00:00
Mathieu Lirzin b37e315aef Improved: Use the ‘@Override’ annotation
(OFBIZ-10939)

The ‘@Override’ annotation helps readers understand that the method at
hand is overriding a super class or implementing an interface.
Additionally it allows the compiler to check if the methods annotated
with ‘@Override’ are actually implementing an abstract method.

Using that annotation makes ‘@see foo.bar.ParentClass#myMethod’
comments useless, so those they have been removed for the newly
annotated methods.

Thanks Jacques Le Roux and Swapnil M Mane for acknowledging the commit.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1858295 13f79535-47bb-0310-9956-ffa450edef68
2019-04-27 19:34:25 +00:00
Swapnil Mane dad9391fd0 Fixed: Parameters are not available to the next response type when form of enctype=multipart/form-data type is submitted
(OFBIZ-10833)

Reason: The UtilHttp.getMultiPartParameterMap method is used to get the parameters in case of multipart/form-data type.
The getMultiPartParameterMap parse the request to get the parameters.

{code}
uploadedItems = UtilGenerics.<FileItem>checkList(upload.parseRequest(request));
{code}

As per the Apache commons-fileupload guideline, a request can only be parsed once [1]. So, for the next response, again the same getMultiPartParameterMap method is executed (with the same request object), and no parameters are found, since, the request is already parsed.

Also, have a look at the StackOverflow question [2], it also contains related information.

Fix for the issue:
Set the consumed parameters (except uploaded file(s)) in the request attribute so that it will be available to the next response.
The uploaded file(s) are not set in request attribute again to avoid unnecessary memory consumption, also it makes no sense to traverse the uploaded file in the request.

[1] http://commons.apache.org/proper/commons-fileupload/faq.html#empty-parse

[2] https://stackoverflow.com/questions/13881272/servletfileuploadparserequestrequest-returns-an-empty-list

Thanks: Ingo Wolfmayr for reporting issue and Jacques Le Roux for review.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1858035 13f79535-47bb-0310-9956-ffa450edef68
2019-04-24 09:57:08 +00:00
Mathieu Lirzin 26a2a5fa43 Improved: Use ‘contains’ matcher when possible
(OFBIZ-10941)

It is more precise to use the ‘contains’ matcher when checking the
values, completeness and order of a collection.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1857960 13f79535-47bb-0310-9956-ffa450edef68
2019-04-22 13:47:36 +00:00
Mathieu Lirzin 47ea42c001 Improved: Use ‘containsInAnyOrder’ matcher when possible
(OFBIZ-10941)

It is more precise to use ‘containsInAnyOrder’ matcher than checking
the presence of items and the size of the collections separately.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1857959 13f79535-47bb-0310-9956-ffa450edef68
2019-04-22 13:45:42 +00:00
Mathieu Lirzin 2b541d715d Improved: Check Map equality in ‘MultivaluedMapContextTests’
The equality between two maps is defined by the presence of the same
set of entries in both maps, so checking equality of the maps is
equivalent to checking directly their entries.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1857958 13f79535-47bb-0310-9956-ffa450edef68
2019-04-22 13:43:04 +00:00
Mathieu Lirzin 5982be8161 Improved: Remove unnecessary declared exceptions for ‘ContainerException’
(OFBIZ-10938)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1857913 13f79535-47bb-0310-9956-ffa450edef68
2019-04-21 14:22:36 +00:00
Mathieu Lirzin 990c8a3aab Improved: Remove redundant specification of type arguments
(OFBIZ-10937)

Since Java 1.7, when defining generic types it is unnecessary to
redefine those types in the constructor when it is done in the
declared type.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1857906 13f79535-47bb-0310-9956-ffa450edef68
2019-04-21 12:49:52 +00:00
Mathieu Lirzin e34434000b Fixed: Remove unnecessary semicolons in Java code (OFBIZ-10936)
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1857904 13f79535-47bb-0310-9956-ffa450edef68
2019-04-21 10:55:18 +00:00
Mathieu Lirzin acff8da727 Fixed: Remove unused imports
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1857897 13f79535-47bb-0310-9956-ffa450edef68
2019-04-21 10:10:51 +00:00
Mathieu Lirzin d5e3c2d3d4 Improved: Remove redundant null checks (OFBIZ-10911)
Redundant null checks detected by Eclipse has been removed.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1857896 13f79535-47bb-0310-9956-ffa450edef68
2019-04-21 09:37:49 +00:00
Mathieu Lirzin d7127ce9ea Fixed: Ensure that ‘MapContext’ preserves insertion order properties
(OFBIZ-10933)

This fixes a regression introduced in revision 1837462.

When pushing a ‘LinkedHashMap’ inside a ‘MapContext’, the iteration
order of the ‘MapContext’ values was not corresponding to the
insertion order of the embedded ‘LinkedHashMap’ which is important in
the ‘ControllerConfig’ case where configuration elements are stored in
‘LinkedHashMap’ objects and the ‘include’ mechanism relies on
‘MapContext’.

To avoid such regression in the future, a test reproducing the bug has
been added.

Thanks: Gil Portenseigne for investigating.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1857818 13f79535-47bb-0310-9956-ffa450edef68
2019-04-19 15:02:25 +00:00
Mathieu Lirzin 60a6ac1047 Improved: Add ‘UtilMisc#toMap(Supplier<Map<K, V>>, Object...)’
(OFBIZ-10933)

It is convenient to use ‘UtilMisc#toMap’ to create pseudo-literal
maps. Previously it was not possible to specify the concrete class of
the constructed map.  The ‘UtilMisc#toMap(Supplier<Map<K, V>>,
Object...)’ overload now provides a convenient way to instantiate
specific map types like ‘LinkedHashMap’ objects.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1857817 13f79535-47bb-0310-9956-ffa450edef68
2019-04-19 14:57:54 +00:00
Jacques Le Roux 13a86c1c87 Improved: Improve ObjectInputStream class
(OFBIZ-10837)

Fixes CVE-2019-0189

Cleans and simplifies things in UtilObject.java and also handles patterns. 
That's what we missed most when needing to update.

Fixes typos in SafeObjectInputStream class and add a commented line for a WIP in
resolveProxyClass method

Also includes work done in UtilObject.java for OFBIZ-9855 
"Using try-with-resources with File IO Objects."




git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1857392 13f79535-47bb-0310-9956-ffa450edef68
2019-04-12 09:29:03 +00:00