Skip to content

Small numbers get transformed into negative exponentials #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 tasks done
spassarop opened this issue Aug 30, 2021 · 1 comment
Closed
5 tasks done

Small numbers get transformed into negative exponentials #80

spassarop opened this issue Aug 30, 2021 · 1 comment

Comments

@spassarop
Copy link

Bug Report

Prerequisites

  • Can you reproduce the problem in a MWE?
  • Are you running the latest version of AngleSharp?
  • Did you check the FAQs to see if that helps you?
  • Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g., AngleSharp.Css for CSS support)
  • Did you perform a search in the issues?

For more information, see the CONTRIBUTING guide.

Description

Small numbers like 0.00001 get transformed into exponentials like 1E-05 due to internal value parsing. This does not happen with large numbers like 100000000.

Steps to Reproduce

  1. Create a declaration containing a margin-left (could be any margin side) with a value of 0.00001px. I just used the first test on src\AngleSharp.Css.Tests\Declarations\CssMarginProperty.cs and changed it to my test values. It could be:
    var snippet = "margin-left: 0.00001px";
    In my project which consumes AngleSharp.Css I used CssParser.ParseStyleSheet() and inspecting the result, the property was in exponential format. This would skip the next two steps.
  2. Parse the snippet with ParseDeclaration:
    var property = ParseDeclaration(snippet);
  3. Check that property value is now in exponential format.

Expected behavior: Output is margin-left: 0.00001px.

Actual behavior: Output is margin-left: 1E-05px. I wouldn't mind if I use the value to apply on CSS as it's semantically the same. The problem is that the use I give AngleSharp.Css is to clean bad styles on a general HTML, looking for malicious input. Users of my library expect to receive the same HTML they used as input to clean.

Environment details: Windows 10, .NET Core 2.1, AngleSharp.Css 0.16.1, AngleSharp 0.16.0.

Possible Solution

This one is too deep for me; I don't know the internals of the project that much to propose a solution 😞

@spassarop spassarop added the bug label Aug 30, 2021
FlorianRappl added a commit that referenced this issue Nov 4, 2021
@FlorianRappl
Copy link
Contributor

Available in devel / preview version (upcoming 0.16.2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants