parush / elmah

Automatically exported from code.google.com/p/elmah
0 stars 0 forks source link

Line breaks in subject when mailing error messages #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Recently received issues when trying to handle errors where the message
contains line breaks. e.g. when connecting to a database with incorrect
login credentials the message returned is across two lines:

What steps will reproduce the problem?
===============
1. Change connection string dbname or login credentials so that
authentication will fail (I used sql server 2000).
2. Enter debugging
3. InvalidArgumentException is thrown at line 233 of ErrorMailModule.cs -
"The specified string is not in the form required for a subject."

What is the expected output? What do you see instead?
===============
Cannot open database requested in login 'DATABASENAME'. Login fails.
Login failed for user 'PCNAME\ASPNET'.

If the message is configured to be included in the subject line when using
the ErrorMailModule, an exception is thrown indicating an invalid subject line.

What version of the product are you using? On what operating system?
===============
Win2K3, .NET 2.0, SQL Server 2000

Please provide any additional information below.
This issue has been recreated from the still active gotdotnet workspace
which will be discontinued shortly,
http://www.gotdotnet.com/workspaces/bugtracker/bugdetails.aspx?id=f18bab11-162c-
4267-a46e-72438c38df6f&bugid=005e4343-93c1-42c4-b4b0-d4aaab5751d9

Suggested fix on line 233 of ErrorMailModule.cs
===============
Replace:
mail.Subject = string.Format(subjectFormat, error.Message, error.Type);

With
mail.Subject = string.Format(subjectFormat, Regex.Replace( error.Message,
"[\r\n]+", " ", RegexOptions.Compiled ), error.Type);

Original issue reported on code.google.com by dave.tra...@gmail.com on 7 Jun 2007 at 8:35

GoogleCodeExporter commented 9 years ago
Heres a svn diff for the above. 

Original comment by jason.fi...@gmail.com on 21 Jun 2007 at 3:31

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by azizatif on 21 Jun 2007 at 8:45

GoogleCodeExporter commented 9 years ago

Original comment by azizatif on 21 Jun 2007 at 8:47

GoogleCodeExporter commented 9 years ago

Original comment by azizatif on 21 Jun 2007 at 8:56