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

CssSchema: Allow negative token values for margin property #184

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions src/main/java/org/owasp/html/CssSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ Property forKey(String propertyName) {
Property fontWeight = new Property(
0, union(fontLiterals0, fontStyleLiterals0), zeroFns);
builder.put("font-weight", fontWeight);
Property height = new Property(5, bottomLiterals0, zeroFns);
Property height = new Property(1, bottomLiterals0, zeroFns);
builder.put("height", height);
Property letterSpacing = new Property(5, fontStyleLiterals0, zeroFns);
builder.put("letter-spacing", letterSpacing);
Expand All @@ -654,8 +654,7 @@ Property forKey(String propertyName) {
Property listStyleType = new Property(
0, union(listStyleLiterals0, listStyleLiterals2), zeroFns);
builder.put("list-style-type", listStyleType);
Property margin = new Property(1, bottomLiterals0, zeroFns);
builder.put("margin", margin);
builder.put("margin", bottom);
Property maxHeight = new Property(1, maxHeightLiterals0, zeroFns);
builder.put("max-height", maxHeight);
Property opacity = new Property(1, mozOpacityLiterals0, zeroFns);
Expand Down Expand Up @@ -803,14 +802,14 @@ Property forKey(String propertyName) {
builder.put("border-width", mozOutlineWidth);
builder.put("cue-after", cue);
builder.put("cue-before", cue);
builder.put("left", height);
builder.put("margin-bottom", margin);
builder.put("margin-left", margin);
builder.put("margin-right", margin);
builder.put("margin-top", margin);
builder.put("left", bottom);
builder.put("margin-bottom", bottom);
builder.put("margin-left", bottom);
builder.put("margin-right", bottom);
builder.put("margin-top", bottom);
builder.put("max-width", maxHeight);
builder.put("min-height", margin);
builder.put("min-width", margin);
builder.put("min-height", maxHeight);
builder.put("min-width", maxHeight);
builder.put("outline", mozOutline);
builder.put("outline-color", mozOutlineColor);
builder.put("outline-style", mozOutlineStyle);
Expand All @@ -826,13 +825,13 @@ Property forKey(String propertyName) {
builder.put("pause-before", borderSpacing);
builder.put("pitch-range", borderSpacing);
builder.put("richness", borderSpacing);
builder.put("right", height);
builder.put("right", bottom);
builder.put("stress", borderSpacing);
builder.put("text-indent", borderSpacing);
builder.put("text-overflow", oTextOverflow);
builder.put("text-shadow", boxShadow);
builder.put("top", height);
builder.put("width", margin);
builder.put("top", bottom);
builder.put("width", height);
builder.put("word-spacing", letterSpacing);
builder.put("z-index", bottom);
builder.put("rgba()", rgb$Fun);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/owasp/html/AntiSamyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public static void testPreviousBugs() {

/* issue #25 */
assertEquals(
"<div>Test</div>", sanitize("<div style=\"margin: -5em\">Test</div>"));
"<div>Test</div>", sanitize("<div style=\"margin: xxx\">Test</div>"));


/* issue #28 */
Expand Down