@@ -44,7 +44,7 @@ public CrashReport(ReportCrash reportCrashObject)
4444 SendAnonymousReport ( ) ;
4545 }
4646
47- public override sealed string Text
47+ public sealed override string Text
4848 {
4949 get { return base . Text ; }
5050 set { base . Text = value ; }
@@ -59,8 +59,7 @@ private void CrashReportLoad(object sender, EventArgs e)
5959 textBoxMessage . Text = _reportCrash . Exception . Message ;
6060 textBoxTime . Text = DateTime . Now . ToString ( CultureInfo . InvariantCulture ) ;
6161 textBoxSource . Text = _reportCrash . Exception . Source ;
62- textBoxStackTrace . Text = string . Format ( "{0}\n {1}" , _reportCrash . Exception . InnerException ,
63- _reportCrash . Exception . StackTrace ) ;
62+ textBoxStackTrace . Text = $@ "{ _reportCrash . Exception . InnerException } \n{ _reportCrash . Exception . StackTrace } ";
6463 }
6564
6665 private void CrashReport_Shown ( object sender , EventArgs e )
@@ -93,9 +92,9 @@ private void ButtonSendReportClick(object sender, EventArgs e)
9392 var fromAddress = ! string . IsNullOrEmpty ( _reportCrash . FromEmail ) ? new MailAddress ( _reportCrash . FromEmail ) : null ;
9493 var toAddress = new MailAddress ( _reportCrash . ToEmail ) ;
9594
96- const string r0_255 = @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])" ;
95+ const string r0To255 = @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])" ;
9796 var regexEmail = new Regex ( @"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
98- + @"((" + r0_255 + @"\." + r0_255 + @"\." + r0_255 + @"\." + r0_255 + @"){1}|"
97+ + @"((" + r0To255 + @"\." + r0To255 + @"\." + r0To255 + @"\." + r0To255 + @"){1}|"
9998 + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$" ) ;
10099 var subject = "" ;
101100
@@ -122,14 +121,13 @@ private void ButtonSendReportClick(object sender, EventArgs e)
122121 {
123122 errorProviderEmail . SetError ( textBoxEmail , "" ) ;
124123 fromAddress = new MailAddress ( textBoxEmail . Text . Trim ( ) ) ;
125- subject = string . Format ( "{0} {1} Crash Report by {2}" , _reportCrash . ApplicationTitle ,
126- _reportCrash . ApplicationVersion , textBoxEmail . Text . Trim ( ) ) ;
124+ subject =
125+ $ " { _reportCrash . ApplicationTitle } { _reportCrash . ApplicationVersion } Crash Report by { textBoxEmail . Text . Trim ( ) } " ;
127126 }
128127 }
129128 if ( string . IsNullOrEmpty ( subject . Trim ( ) ) )
130129 {
131- subject = string . Format ( "{0} {1} Crash Report" , _reportCrash . ApplicationTitle ,
132- _reportCrash . ApplicationVersion ) ;
130+ subject = $ "{ _reportCrash . ApplicationTitle } { _reportCrash . ApplicationVersion } Crash Report";
133131 }
134132
135133 if ( _reportCrash . AnalyzeWithDoctorDump )
@@ -282,81 +280,80 @@ private string HtmlReport()
282280 CreateReport ( _reportCrash . Exception ) ) ;
283281 if ( ! String . IsNullOrEmpty ( textBoxUserMessage . Text . Trim ( ) ) )
284282 {
285- report += string . Format ( @"<br/>
283+ report += $ @ "<br/>
286284 <div class=""content"">
287285 <div class=""title"" style=""background-color: #66FF99;"">
288286 <h3>User Comment</h3>
289287 </div>
290288 <div class=""message"">
291- <p>{0 }</p>
289+ <p>{ HttpUtility . HtmlEncode ( textBoxUserMessage . Text . Trim ( ) ) } </p>
292290 </div>
293- </div>" , HttpUtility . HtmlEncode ( textBoxUserMessage . Text . Trim ( ) ) ) ;
291+ </div>" ;
294292 }
295293 if ( ! String . IsNullOrEmpty ( _reportCrash . DeveloperMessage . Trim ( ) ) )
296294 {
297- report += string . Format ( @"<br/>
295+ report += $ @ "<br/>
298296 <div class=""content"">
299297 <div class=""title"" style=""background-color: #66FF99;"">
300298 <h3>Developer Message</h3>
301299 </div>
302300 <div class=""message"">
303- <p>{0 }</p>
301+ <p>{ HttpUtility . HtmlEncode ( _reportCrash . DeveloperMessage . Trim ( ) ) } </p>
304302 </div>
305- </div>" , HttpUtility . HtmlEncode ( _reportCrash . DeveloperMessage . Trim ( ) ) ) ;
303+ </div>" ;
306304 }
307305 report += "</body></html>" ;
308306 return report ;
309307 }
310308
311309 private string CreateReport ( Exception exception )
312310 {
313- string report = string . Format ( @"<br/>
311+ string report = $ @ "<br/>
314312 <div class=""content"">
315313 <div class=""title"" style=""background-color: #66CCFF;"">
316314 <h3>Exception Type</h3>
317315 </div>
318316 <div class=""message"">
319- <p>{0 }</p>
317+ <p>{ HttpUtility . HtmlEncode ( exception . GetType ( ) . ToString ( ) ) } </p>
320318 </div>
321319 </div><br/>
322320 <div class=""content"">
323321 <div class=""title"" style=""background-color: #66CCFF;"">
324322 <h3>Error Message</h3>
325323 </div>
326324 <div class=""message"">
327- <p>{1 }</p>
325+ <p>{ HttpUtility . HtmlEncode ( exception . Message ) } </p>
328326 </div>
329327 </div><br/>
330328 <div class=""content"">
331329 <div class=""title"" style=""background-color: #66CCFF;"">
332330 <h3>Source</h3>
333331 </div>
334332 <div class=""message"">
335- <p>{2 }</p>
333+ <p>{ HttpUtility . HtmlEncode ( exception . Source ?? "No source" ) } </p>
336334 </div>
337335 </div><br/>
338336 <div class=""content"">
339337 <div class=""title"" style=""background-color: #66CCFF;"">
340338 <h3>Stack Trace</h3>
341339 </div>
342340 <div class=""message"">
343- <p>{3}</p>
341+ <p>{
342+ HttpUtility . HtmlEncode ( exception . StackTrace ?? "No stack trace" ) . Replace ( "\r \n " , "<br/>" )
343+ } </p>
344344 </div>
345- </div>" , HttpUtility . HtmlEncode ( exception . GetType ( ) . ToString ( ) ) ,
346- HttpUtility . HtmlEncode ( exception . Message ) ,
347- HttpUtility . HtmlEncode ( exception . Source ?? "No source" ) ,
348- HttpUtility . HtmlEncode ( exception . StackTrace ?? "No stack trace" ) . Replace ( "\r \n " , "<br/>" ) ) ;
345+ </div>" ;
349346 if ( exception . InnerException != null )
350347 {
351- report += string . Format ( @"<br/>
348+ report += $ @ "<br/>
352349 <div class=""content"">
353350 <div class=""title"" style=""background-color: #66CCFF;"">
354351 <h3>Inner Exception</h3>
355352 </div>
356353 <div class=""message"">
357- {0 }
354+ { CreateReport ( exception . InnerException ) }
358355 </div>
359- </div>" , CreateReport ( exception . InnerException ) ) ;
356+ </div>" ;
360357 }
361358 report += "<br/>" ;
362359 return report ;
0 commit comments