-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure external sources for styles only process CSS responses when in…
…lining stylesheets
- Loading branch information
1 parent
3c70622
commit e07d661
Showing
3 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
PreMailer.Net/PreMailer.Net/Extensions/WebResponseExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Net; | ||
|
||
namespace PreMailer.Net.Extensions | ||
{ | ||
public static class WebResponseExtensions | ||
{ | ||
public static string ParseContentType(this WebResponse response) | ||
{ | ||
if(response == null) | ||
throw new NullReferenceException("Malformed response detected when parsing WebResponse Content-Type"); | ||
|
||
if(string.IsNullOrEmpty(response.ContentType)) | ||
throw new NullReferenceException("Malformed Content-Type response detected when parsing WebResponse"); | ||
|
||
var results = response.ContentType.Split(';'); | ||
|
||
if(results.Length == 0) | ||
throw new FormatException("Malformed Content-Type response detected when parsing WebResponse"); | ||
|
||
return results[0]; | ||
} | ||
} | ||
} |