Skip to content

Commit

Permalink
Merge pull request #111 from bigsan/encodingfix
Browse files Browse the repository at this point in the history
encoding problem fixed.
  • Loading branch information
jamietre committed Jul 29, 2013
2 parents 30b56cf + 850870e commit 59724ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 14 additions & 2 deletions source/CsQuery.Tests/Core/WebIO/QueryRemoteServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@ public override void FixtureSetUp()
base.FixtureSetUp();
ServerConfig.Default.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
}

[Test,TestMethod]

[Test, TestMethod]
public void GetHtmlWhoseContentTypeHasNoCharset()
{
var url = "http://www.pixnet.net";

Dom = CQ.CreateFromUrl(url);

Assert.IsTrue(Dom.Document != null, "Dom was created");
var csq = Dom.Find("title:contains('痞客邦 PIXNET')");
Assert.IsTrue(csq.Length > 0, "I found an expected content container - if Pixnet changed their web site this could fail.");
}

[Test, TestMethod]
public void GetHtml()
{
var url = urls[0];
Expand Down
3 changes: 2 additions & 1 deletion source/CsQuery/Web/CsqWebRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ public static Encoding GetEncoding(IHttpWebResponse response)
{
Encoding encoding = null;

if (!String.IsNullOrEmpty(response.CharacterSet)) {
if (!String.IsNullOrEmpty(response.CharacterSet)
&& response.ContentType.Contains("charset=")) {
HtmlParser.HtmlEncoding.TryGetEncoding(response.CharacterSet, out encoding);
}

Expand Down

0 comments on commit 59724ca

Please sign in to comment.