Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0048088Openbravo ERPA. Platformpublic2021-11-16 12:002021-12-14 15:30
alostale 
AugustoMauch 
immediateminorhave not tried
closedfixed 
5
 
PR21Q3.6PR21Q3.6 
Core
Production - Confirmed Stable
2020-01-10
3.0PR20Q2
https://code.openbravo.com/erp/devel/pi/rev/b032fd12d0bc000fff7bd8a786b0238b4bb1824a [^]
No
0048088: OOM compressing JS with certain regexp
If the JavaScript included by ComponentProviders includes certain type of regular expressions, an OOM is thrown when it is tried to be compressed.

Note this OOM is captured and the original contents without compression is returned so this issue has no impact on the functionality.
1. Include this line in any JavaScript:
  const letsCrash = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*$/;

2. With no module in development serve the JavaScript containing that line:
ERROR in logs:
    at java.util.Arrays.copyOf(Arrays.java:3745) ~[?:?]
    at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:120) ~[?:?]
    at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:95) ~[?:?]
    at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:137) ~[?:?]
    at org.openbravo.client.kernel.JSMin.action(JSMin.java:188) ~[classes/:?]
    at org.openbravo.client.kernel.JSMin.jsmin(JSMin.java:295) ~[classes/:?]
    at org.openbravo.client.kernel.JSCompressor.compress(JSCompressor.java:57) [classes/:?]

Alternatively execute regexCompression test from MR [1].

---
[1] https://gitlab.com/openbravo/product/openbravo/-/merge_requests/457/ [^]
No tags attached.
blocks defect 0048070 closed platform OOM compressing JS with certain regexp 
Issue History
2021-11-17 10:43AugustoMauchTypedefect => backport
2021-11-17 10:43AugustoMauchTarget Version => PR21Q3.6
2021-11-17 11:50hgbotNote Added: 0133141
2021-11-17 12:21hgbotResolutionopen => fixed
2021-11-17 12:21hgbotStatusscheduled => closed
2021-11-17 12:21hgbotFixed in Version => PR21Q3.6
2021-11-17 12:21hgbotNote Added: 0133145
2021-11-17 12:21hgbotNote Added: 0133146
2021-12-14 15:30cbernerAssigned Toplatform => AugustoMauch

Notes
(0133141)
hgbot   
2021-11-17 11:50   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/459 [^]
(0133145)
hgbot   
2021-11-17 12:21   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 9b4b045400006a4a828539f0ac474b584248b79a
Author: Asier Lostalé <asier.lostale@openbravo.com>
Date: 2021-11-17T11:58:59+01:00
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/9b4b045400006a4a828539f0ac474b584248b79a [^]

fixed BUG-48088: OOM compressing JS with certain regexp

When trying to compress a JS containing a matching for a single
character which includes the / character followed by the ` character an
OOM was produced. Ie. /[/`]/

This was caused by incorrectly detecting the / chracter inside the
single character matching group as regexp termination instead of as /
single character.

Note that other cases including other matching other quotes agfter /
character would have thrown an UnterminatedStringLiteralException.

This is fixed by taking into account when a regexp is inside a single
character match not to consider / as regexp termination.

---
M modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/test/CompressionTest.java
M modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/JSMin.java
---
(0133146)
hgbot   
2021-11-17 12:21   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/459 [^]