Menu

#86 LexicalUnitImpl float value conversion to String formatting error

0.9.27
closed
RBRi
None
1
2019-03-23
2019-03-21
Erica
No

Microsoft Outlook produces some slightly unusual css when creating emails. One such example is:

margin-bottom: 0.0001pt;

Using the cssparser on such content exposes a bug in the LexicalUnitImpl class with how the float value is converted into a String. The String is in scientific notation and includes the exponent:

margin-bottom: 1.0E-4pt;

As I thought it helpful I've attached a small patch which includes a new unit test for the exponent issue and also a fix for converting the float value to a String.

Erica

1 Attachments

Discussion

  • Erica

    Erica - 2019-03-21

    Updated patch that will format the number correctly regarless of Locale

     
  • RBRi

    RBRi - 2019-03-21

    Thansk for the patch? Just one question

    decimalFormat_.setMaximumFractionDigits(4);
    

    why you choose 4 here?

     
  • Erica

    Erica - 2019-03-21

    A somewhat arbitary number, it was enough precision for the particular Microsoft Outlook case. Although that level of precision for the margin is likely unnecessary and will probably get rounded to 0 when a webview renders the content.

     
  • RBRi

    RBRi - 2019-03-21
    • status: open --> closed
    • assigned_to: RBRi
     
  • RBRi

    RBRi - 2019-03-21

    Many thanks. Do you need a new release?

     
  • Erica

    Erica - 2019-03-21

    If it's not too much trouble that would really handy to pick up this fix

     
    • RBRi

      RBRi - 2019-03-21

      Ok will do it over the weekend after some more tests.

       

      Last edit: RBRi 2019-03-23
  • RBRi

    RBRi - 2019-03-23

    The new release is out; many thanks for your contribution.

     

Anonymous
Anonymous

Add attachments
Cancel