Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0036683Openbravo ERPA. Platformpublic2017-08-22 09:022017-09-21 16:49
adrianromero 
caristu 
urgentmajorhave not tried
closedfixed 
5
 
3.0PR17Q4 
alostale
User Interface Client Kernel
No
0036683: CSS minifier breaks @font-face directives
Adding CSS (stylesheet) resource files that contains @font-face directives in a module using BaseComponentProvider breaks the generated minified stylesheet.

The minifier manages incorrectly quotations. For example translates this:

@font-face {
  font-family: 'Roboto-Condensed-Bold';
  src: url('./../font/Roboto-Condensed/Roboto-Condensed-Bold.woff') format('woff');
}

Into this:

@font-face{font-family: 'Roboto-Condensed-Bold';src: url(./../font/Roboto-Condensed/Roboto-Condensed-Bold.woff') format('woff);}

Observe that it has been removed the first quote in url(... and the last quote in format(...

This problems seems to be located near:

https://code.openbravo.com/erp/devel/pi/file/c272160f0246/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StyleSheetResourceComponent.java#l201 [^]
For example in the org.openbravo.retail.posterminal component provider OBPOSComponentProvider add a new css file that includes a @font-face directive like

@font-face {
  font-family: 'Roboto-Condensed-Bold';
  src: url('./../font/Roboto-Condensed/Roboto-Condensed-Bold.woff') format('woff');
}

Set the module in non development mode to activate the css minifier and load POS

Observe that in the css generated the quotes has been wrongly managed
No tags attached.
related to feature request 0025574 closed dbaz Openbravo ERP Upgrade SmartClient 10.0d 
has duplicate feature request 0036014 new jorge-garcia Retail Modules Include source maps for our javascript files 
related to defect 0036708 closed dbaz Openbravo ERP CSSMinimizer does not work well with "transform-origin" property 
Issue History
2017-08-22 09:02adrianromeroNew Issue
2017-08-22 09:02adrianromeroAssigned To => platform
2017-08-22 09:02adrianromeroModules => Core
2017-08-22 09:02adrianromeroTriggers an Emergency Pack => No
2017-08-22 09:02adrianromeroModulesCore => User Interface Client Kernel
2017-08-23 08:47caristuAssigned Toplatform => caristu
2017-08-23 08:47caristuRelationship addedrelated to 0025574
2017-08-23 09:49hgbotCheckin
2017-08-23 09:49hgbotNote Added: 0098587
2017-08-23 09:49hgbotStatusnew => resolved
2017-08-23 09:49hgbotResolutionopen => fixed
2017-08-23 09:49hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/573badaa70f519eab4de9ea2787985ca16fb544e [^]
2017-08-23 09:49caristuReview Assigned To => alostale
2017-08-24 08:31caristuRelationship addedrelated to 0036708
2017-08-25 10:01caristuNote Added: 0098647
2017-08-25 10:07hgbotCheckin
2017-08-25 10:07hgbotNote Added: 0098648
2017-08-25 10:07hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/573badaa70f519eab4de9ea2787985ca16fb544e [^] => http://code.openbravo.com/erp/devel/pi/rev/73827432edb31f02b641f50b7c7be02901733106 [^]
2017-08-25 10:07caristuNote Edited: 0098647bug_revision_view_page.php?bugnote_id=0098647#r15709
2017-08-28 09:56alostaleRelationship addedhas duplicate 0036014
2017-08-29 08:55alostaleNote Added: 0098681
2017-08-29 08:55alostaleStatusresolved => closed
2017-08-29 08:55alostaleFixed in Version => 3.0PR17Q4
2017-09-21 16:49hudsonbotCheckin
2017-09-21 16:49hudsonbotNote Added: 0099319
2017-09-21 16:49hudsonbotCheckin
2017-09-21 16:49hudsonbotNote Added: 0099329

Notes
(0098587)
hgbot   
2017-08-23 09:49   
Repository: erp/devel/pi
Changeset: 573badaa70f519eab4de9ea2787985ca16fb544e
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Wed Aug 23 09:42:26 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/573badaa70f519eab4de9ea2787985ca16fb544e [^]

fixes issue 36683: CSS minifier breaks @font-face directives

CSSMinimizer have problems dealing with selectors like url('data:image/....'). The url content need to be surrounded with double quotes in order to minimize it properly. For this reason a regular expression is used in order to replace the single quotes of the url definition with double quotes.

The problem here was that if additional single quotes appeared after the url definition, like for example:

  src: url('./../font/Roboto-Condensed/Roboto-Condensed-Bold.woff') format('woff');

the replacement was not being done properly.

To fix the problem the regular expression has been changed in order to look for the closing quote of the url content. Thus, we ensure that we are replacing just the single quotes of the url value.

---
M modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StyleSheetResourceComponent.java
---
(0098647)
caristu   
2017-08-25 10:01   
(edited on: 2017-08-25 10:07)
The original problem of the CSSMinimizer dealing with selectors like url('data:image/....') is solved in the latest version of the CSSMin library[1].

That change also fixes this issue.

After discussing it with dbaz we are agree to apply the same fix on our library and let the library fix the problem instead of pre-processing anything.

[1] https://github.com/barryvan/CSSMin/commit/fc2f1305d9624cc71725522be3b61c0a84b18d95 [^]

(0098648)
hgbot   
2017-08-25 10:07   
Repository: erp/devel/pi
Changeset: 73827432edb31f02b641f50b7c7be02901733106
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Fri Aug 25 10:06:32 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/73827432edb31f02b641f50b7c7be02901733106 [^]

fixes issue 36683: CSS minifier breaks @font-face directives

 Apply the CSSMin library[1] original solution to handle url expressions properly on the CSSMinimizer java class. This way the pre-processing to replace the single quotes with double quotes done before passing the CSS content to the minimizer is no longer needed

[1] https://github.com/barryvan/CSSMin/commit/fc2f1305d9624cc71725522be3b61c0a84b18d95 [^]

---
M modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/CSSMinimizer.java
M modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StyleSheetResourceComponent.java
---
(0098681)
alostale   
2017-08-29 08:55   
reviewed

tested:

-reported case
-css in core is not affected by this changes, so minified css does not differ from previous version
(0099319)
hudsonbot   
2017-09-21 16:49   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9750b78d3e5c [^]
Maturity status: Test
(0099329)
hudsonbot   
2017-09-21 16:49   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9750b78d3e5c [^]
Maturity status: Test