Skip to content

Commit

Permalink
Fix #44
Browse files Browse the repository at this point in the history
  • Loading branch information
mganss committed Sep 14, 2015
1 parent edd0ad4 commit 486be15
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions HtmlSanitizer.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2263,6 +2263,23 @@ public void MultipleRecipientsTest()
var expected = @"<a>Bang Bang</a>";
Assert.That(actual, Is.EqualTo(expected).IgnoreCase);
}

[Test]
public void QuotedBackgroundImageTest()
{
// https://github.com/mganss/HtmlSanitizer/issues/44

// Arrange
var s = new HtmlSanitizer();

// Act
var htmlFragment = "<div style=\"background-image: url('some/random/url.img')\"></div>";
var actual = s.Sanitize(htmlFragment);

// Assert
var expected = "<div style=\"background-image: url('some/random/url.img')\"></div>";
Assert.That(actual, Is.EqualTo(expected).IgnoreCase);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion HtmlSanitizer/HtmlSanitizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ private bool IsAllowedAttribute(KeyValuePair<string, string> attribute)
private static readonly Regex CssComments = new Regex(@"/\*.*?\*/", RegexOptions.Compiled);
// IE6 <http://heideri.ch/jso/#80>
private static readonly Regex CssExpression = new Regex(@"[eE\uFF25\uFF45][xX\uFF38\uFF58][pP\uFF30\uFF50][rR\u0280\uFF32\uFF52][eE\uFF25\uFF45][sS\uFF33\uFF53]{2}[iI\u026A\uFF29\uFF49][oO\uFF2F\uFF4F][nN\u0274\uFF2E\uFF4E]", RegexOptions.Compiled);
private static readonly Regex CssUrl = new Regex(@"[Uu][Rr\u0280][Ll\u029F]\s*\(\s*['""]?\s*([^'"")]+)", RegexOptions.Compiled);
private static readonly Regex CssUrl = new Regex(@"[Uu][Rr\u0280][Ll\u029F]\s*\(([^)]+)", RegexOptions.Compiled);

/// <summary>
/// Sanitizes the style.
Expand Down

0 comments on commit 486be15

Please sign in to comment.