Skip to content
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

Update length regexes on example policies #102

Merged
merged 2 commits into from
Aug 29, 2021
Merged

Conversation

spassarop
Copy link
Collaborator

@spassarop spassarop commented Aug 23, 2021

The tests have comments explaining the bug (#101) and a single case that passes but involves a latent bug.

@bijarniy
Copy link

Hi @spassarop, Could you please share if anything is pending for this PR to merge. Is this issue #101 stands resolved now?

@spassarop
Copy link
Collaborator Author

@davewichers are you OK with this PR?

// When using exponential directly the "e" or "E" is internally considered as the start of
// the dimension/unit type. This creates inconsistencies that make the regex validation fail,
// also in cases like 1e4pt where "e" is considered as dimension instead of "pt".
assertThat(as.scan("<p style=\"margin: 1.0E+4pt;\">Some text.</p>", policy, AntiSamy.DOM).getCleanHTML(), not(containsString("margin")));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, the GitHub issue that originally was brought up was when someone was trying to use a fractional point, something like 0.001pt or whatever. This tests for a margin of 10000pt which seems a bit excessive. (Had Fermat had that much room in his margins, "Fermat's Last Theorem" likely would have never been a thing! :)
Anyway, my point is, there should be at least something here with a negative exponent to test the original use case that was causing the problem.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the point, 10000pt was just to test the behavior of a positive exponential (also 0.0001 is excesively low for a margin in my opinion). Test was introduced.

@davewichers
Copy link
Collaborator

@davewichers are you OK with this PR?

I'm OK with whatever you decide here.

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

Successfully merging this pull request may close these issues.

4 participants