Skip to content

Commit

Permalink
Merge pull request #136 from daptiv/issue120
Browse files Browse the repository at this point in the history
Fixed NullRef, serialized DTO can be null
  • Loading branch information
mythz committed Apr 14, 2012
2 parents 9e24486 + 7268868 commit cba794d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ServiceStack/WebHost.EndPoints/Formats/HtmlFormat.cs
Expand Up @@ -41,7 +41,8 @@ public void SerializeToStream(IRequestContext requestContext, object dto, IHttpR
&& httpReq.ResponseContentType != ContentType.JsonReport) return;

// Serialize then escape any potential script tags to avoid XSS when displaying as HTML
var json = JsonSerializer.SerializeToString(dto).Replace("<", "&lt;").Replace(">", "&gt;");
var json = JsonSerializer.SerializeToString(dto) ?? "null";
json = json.Replace("<", "&lt;").Replace(">", "&gt;");

var url = httpReq.AbsoluteUri
.Replace("format=html", "")
Expand Down

0 comments on commit cba794d

Please sign in to comment.