Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0048070Openbravo ERPA. Platformpublic2021-11-16 12:002021-11-26 10:54
alostale 
platform 
immediateminorhave not tried
closedfixed 
5
 
PR22Q1 
Core
Production - Confirmed Stable
2020-01-10
3.0PR20Q2
https://code.openbravo.com/erp/devel/pi/rev/b032fd12d0bc000fff7bd8a786b0238b4bb1824a [^]
No
0048070: 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/ [^]
NOR
depends on backport 0048087PR21Q4.2 closed AugustoMauch OOM compressing JS with certain regexp 
depends on backport 0048088PR21Q3.6 closed AugustoMauch OOM compressing JS with certain regexp 
caused by defect 0042475 closed alostale Openbravo JS minimizer does not work well with template literals 
Issue History
2021-11-16 12:00alostaleNew Issue
2021-11-16 12:00alostaleAssigned To => platform
2021-11-16 12:00alostaleModules => Core
2021-11-16 12:00alostaleTriggers an Emergency Pack => No
2021-11-16 12:00alostaleSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=23324#r23324
2021-11-16 12:04hgbotNote Added: 0133101
2021-11-16 12:05alostaleSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=23325#r23325
2021-11-16 12:51alostaleRelationship addedcaused by 0042475
2021-11-16 13:08alostaleRegression level => Production - Confirmed Stable
2021-11-16 13:08alostaleRegression date => 2020-01-10
2021-11-16 13:08alostaleRegression introduced in release => 3.0PR20Q2
2021-11-16 13:08alostaleRegression introduced by commit => https://code.openbravo.com/erp/devel/pi/rev/b032fd12d0bc000fff7bd8a786b0238b4bb1824a [^]
2021-11-16 13:17alostalePrioritynormal => immediate
2021-11-17 10:43AugustoMauchStatusnew => scheduled
2021-11-17 11:34hgbotResolutionopen => fixed
2021-11-17 11:34hgbotStatusscheduled => closed
2021-11-17 11:34hgbotFixed in Version => PR22Q1
2021-11-17 11:34hgbotNote Added: 0133139
2021-11-17 11:34hgbotNote Added: 0133140
2021-11-26 10:54rafarodaTag Attached: NOR

Notes
(0133101)
hgbot   
2021-11-16 12:04   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/457 [^]
(0133139)
hgbot   
2021-11-17 11:34   
Directly closing issue as related merge request is already approved.

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

fixed BUG-48070: 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
---
(0133140)
hgbot   
2021-11-17 11:34   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/457 [^]