codenamejason / elmah

Automatically exported from code.google.com/p/elmah
Apache License 2.0
2 stars 0 forks source link

Invalid XML character in exception message causes "elmah.axd" to break #129

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Log an exception whose message contains the character 0x00
2. Elmah.axd displays YSOD (pasted below)

What version of the product are you using? On what operating system?
version 1.1 rc (1.1.11228)

Please provide any additional information below.

Server Error in '/' Application.
'.', hexadecimal value 0x00, is an invalid character. Line 1, position 186.
Description: An unhandled exception occurred during the execution of the 
current web request. Please review the stack trace for more information 
about the error and where it originated in the code.

Exception Details: System.Xml.XmlException: '.', hexadecimal value 0x00, is 
an invalid character. Line 1, position 186.

Source Error:

An unhandled exception was generated during the execution of the current 
web request. Information regarding the origin and location of the exception 
can be identified using the exception stack trace below.

Stack Trace:

[XmlException: '.', hexadecimal value 0x00, is an invalid character. Line 
1, position 186.]
   System.Xml.XmlTextReaderImpl.Throw(Exception e) +90
   System.Xml.XmlTextReaderImpl.Throw(String res, String[] args) +77
   System.Xml.XmlTextReaderImpl.ThrowInvalidChar(Int32 pos, Char invChar) 
+185
   System.Xml.XmlTextReaderImpl.ParseNumericCharRefInline(Int32 startPos, 
Boolean expand, BufferBuilder internalSubsetBuilder, Int32& charCount, 
EntityType& entityType) +495
   System.Xml.XmlTextReaderImpl.ParseNumericCharRef(Boolean expand, 
BufferBuilder internalSubsetBuilder, EntityType& entityType) +44
   System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean 
isInAttributeValue, EntityExpandType expandType, Int32& charRefEndPos) 
+1797749
   System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char 
quoteChar, NodeData attr) +716
   System.Xml.XmlTextReaderImpl.ParseAttributes() +879
   System.Xml.XmlTextReaderImpl.ParseElement() +545
   System.Xml.XmlTextReaderImpl.ParseDocumentContent() +447
   System.Xml.XmlTextReaderImpl.Read() +41
   System.Xml.XmlReader.MoveToContent() +70
   System.Xml.XmlReader.IsStartElement(String name) +15
   Elmah.SqlErrorLog.ErrorsXmlToList(XmlReader reader, IList 
errorEntryList) in c:\builds\ELMAH\src\Elmah\SqlErrorLog.cs:310
   Elmah.SqlErrorLog.GetErrors(Int32 pageIndex, Int32 pageSize, IList 
errorEntryList) in c:\builds\ELMAH\src\Elmah\SqlErrorLog.cs:186
   Elmah.ErrorLogPage.OnLoad(EventArgs e) in 
c:\builds\ELMAH\src\Elmah\ErrorLogPage.cs:76
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean 
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

Original issue reported on code.google.com by btoliver...@gmail.com on 28 Jul 2009 at 4:15

GoogleCodeExporter commented 9 years ago
i have the same error, but with another hexadecimal code 0x04, PLEASE SAME HELP!

Original comment by lizbeth....@gmail.com on 18 Sep 2009 at 7:12

GoogleCodeExporter commented 9 years ago
I have the same issue with 0x1A and the following error message:

Server Error in '/' Application.
'', hexadecimal value 0x1A, is an invalid character. Line 1, position 183.
Description: An unhandled exception occurred during the execution of the 
current web
request. Please review the stack trace for more information about the error and 
where
it originated in the code.

Exception Details: System.Xml.XmlException: '', hexadecimal value 0x1A, is an
invalid character. Line 1, position 183.

Source Error:

An unhandled exception was generated during the execution of the current web 
request.
Information regarding the origin and location of the exception can be identified
using the exception stack trace below.

Stack Trace:

[XmlException: '', hexadecimal value 0x1A, is an invalid character. Line 1, 
position
183.]
   System.Xml.XmlTextReaderImpl.Throw(Exception e) +76
   System.Xml.XmlTextReaderImpl.Throw(String res, String[] args) +88
   System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String[] args) +18
   System.Xml.XmlTextReaderImpl.ThrowInvalidChar(Int32 pos, Char invChar) +151
   System.Xml.XmlTextReaderImpl.ParseNumericCharRefInline(Int32 startPos, Boolean
expand, BufferBuilder internalSubsetBuilder, Int32& charCount, EntityType&
entityType) +4005958
   System.Xml.XmlTextReaderImpl.ParseNumericCharRef(Boolean expand, BufferBuilder
internalSubsetBuilder, EntityType& entityType) +46
   System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue,
EntityExpandType expandType, Int32& charRefEndPos) +3984053
   System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar,
NodeData attr) +500
   System.Xml.XmlTextReaderImpl.ParseAttributes() +903
   System.Xml.XmlTextReaderImpl.ParseElement() +343
   System.Xml.XmlTextReaderImpl.ParseDocumentContent() +302
   System.Xml.XmlTextReaderImpl.Read() +151
   System.Xml.XmlReader.MoveToContent() +64
   System.Xml.XmlReader.IsStartElement(String name) +18
   Elmah.SqlErrorLog.ErrorsXmlToList(XmlReader reader, IList errorEntryList) in
c:\builds\ELMAH\src\Elmah\SqlErrorLog.cs:310
   Elmah.SqlErrorLog.GetErrors(Int32 pageIndex, Int32 pageSize, IList errorEntryList)
in c:\builds\ELMAH\src\Elmah\SqlErrorLog.cs:186
   Elmah.ErrorLogPage.OnLoad(EventArgs e) in c:\builds\ELMAH\src\Elmah\ErrorLogPage.cs:76
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint) +627

Original comment by theflami...@gmail.com on 28 Jan 2010 at 9:11

GoogleCodeExporter commented 9 years ago
Issue 152 has been merged into this issue.

Original comment by azizatif on 28 Jan 2010 at 8:41

GoogleCodeExporter commented 9 years ago
Thank you, anything I can do to help?

Original comment by steve.go...@gmail.com on 28 Jan 2010 at 8:43

GoogleCodeExporter commented 9 years ago
This reported issue has been reproduced as follows:

IronPython 2.6 (2.6.10920.0) on .NET 2.0.50727.4200
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> clr.AddReference('Elmah')
>>> import System
>>> from System import ApplicationException
>>> from System.Collections import ArrayList
>>> from Elmah import Error, ErrorLog, SqlErrorLog
>>> log = 
SqlErrorLog(r'Server=.\SQLEXPRESS;Database=ELMAH;Trusted_Connection=True')
>>> log.ApplicationName = 'Test'
>>> e = ApplicationException('Exception with char \0.')
>>> log.Log(Error(e))
'038d58a9-75db-4a44-959e-7155d9c4f3fe'
>>> errors = ArrayList()
>>> total = log.GetErrors(0, 10, errors)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: '.', hexadecimal value 0x00, is an invalid character. Line 1, 
position 
162.

Original comment by azizatif on 28 Jan 2010 at 10:02

GoogleCodeExporter commented 9 years ago
This issue has been reproduced in 1.1 release (build 11517).

Original comment by azizatif on 28 Jan 2010 at 10:07

GoogleCodeExporter commented 9 years ago
Attached is a patch that could potentially resolve this issue. It applies to 
1.1 
[1]. Testing and feedback would be appreciated.

[1] http://elmah.googlecode.com/svn/tags/REL-1.1/

Original comment by azizatif on 28 Jan 2010 at 10:53

Attachments:

GoogleCodeExporter commented 9 years ago
Attached are compiled binaries (for testing and feedback only) with the patch 
from 
comment 7 applied to 1.1.

[1] http://code.google.com/p/elmah/issues/detail?id=129#c7

Original comment by azizatif on 29 Jan 2010 at 7:09

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
so just swapping the dll did not sovlve my issue.  I will delete all entries in 
the
db and see if it happens again.

this error came up the first time I deleted all the entries.  Did not return 
after
second attempt:

System.ArgumentNullException: Value cannot be null. Parameter name: s

System.Web.HttpUnhandledException: Exception of type
'System.Web.HttpUnhandledException' was thrown. ---> 
System.ArgumentNullException:
Value cannot be null.
Parameter name: s
   at System.IO.StringReader..ctor(String s)
   at Elmah.SqlErrorLog.GetErrors(Int32 pageIndex, Int32 pageSize, IList errorEntryList)
   at Elmah.ErrorLogPage.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint)
   --- End of inner exception stack trace ---
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.I
ExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously)

Original comment by steve.go...@gmail.com on 2 Feb 2010 at 10:28

GoogleCodeExporter commented 9 years ago
> this error came up the first time I deleted all the entries.
> Did not return after second attempt:

This was an oversight. That attached version should not exhibit this problem 
anymore.

> so just swapping the dll did not sovlve my issue.

That's a shame. Seems to go away on my end with illegal characters in XML. Any 
chance you can send the XML to the error as a comment attachement?

Original comment by azizatif on 2 Feb 2010 at 10:37

Attachments:

GoogleCodeExporter commented 9 years ago
Any further success with the patch? Any chance of getting the XML to the error 
as a 
comment attachement that can be used to reproduce the issue with the patch 
applied?

Original comment by azizatif on 5 Feb 2010 at 6:06

GoogleCodeExporter commented 9 years ago
Here's the XML that I get with this error.  I get mine when I attempt to load 
the 
Elmah.axd page.

Original comment by bmelc...@gmail.com on 19 Feb 2010 at 1:52

Attachments:

GoogleCodeExporter commented 9 years ago
I don't have a DEV environment with me at the moment, but after a little bit of 
Googling I've stumbled across this link: http://msdn.microsoft.com/en-
us/library/ms190025.aspx

Looks like if you've got SQL2005 onwards you can add , TYPE onto the end of the 
FOR 
XML AUTO found in [dbo].[ELMAH_GetErrorsXml] which strips out the #xB character 
(so 
we get FOR XML AUTO, TYPE at the end of the SELECT statement)

Can someone out there have a go and confirm whether or not this makes any 
difference?

Original comment by jamesdriscoll71 on 19 Feb 2010 at 2:40

GoogleCodeExporter commented 9 years ago
> Can someone out there have a go 
> and confirm whether or not this makes any difference?

FOR XML AUTO, TYPE may help but requires MS SQL Server 2005. The patches I 
uploaded 
should be addressing the real crux of the matter; that is, if invalid XML 
characters 
are allowed during the hydration of one error then it should be also allowed 
when a 
page of errors is also being fetched and hydrated. Unfortunately, I haven't 
received 
any confirmation of the patch addressing the issue from the folks having 
raised/starred the issue. According to my tests and theory it should address 
the 
issue but what worries me still is comment #11, which states that the patch 
made no 
difference.

Original comment by azizatif on 19 Feb 2010 at 8:29

GoogleCodeExporter commented 9 years ago
my elmah.axd is now saying 404 file not found.  So Something is up.  Haven't 
had a
chance to look into it but when I do I will give you an update.

Original comment by steve.go...@gmail.com on 20 Feb 2010 at 3:32

GoogleCodeExporter commented 9 years ago
The patch supplied in comment #12 may be subject to the following issue 
reported in 
MSKB article, when a large of errors is requested:

The XML data row is truncated at 2,033 characters when you use the 
SqlDataReader 
object
http://support.microsoft.com/kb/310378

Steps to reproduce:

IronPython 2.6 (2.6.10920.0) on .NET 2.0.50727.4200
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> clr.AddReference(r'Elmah.dll')
>>> from System.Collections import ArrayList
>>> from Elmah import Error, SqlErrorLog
>>> log = 
SqlErrorLog('database=ELMAH;server=.\SQLEXPRESS;Trusted_Connection=True')
>>> log.ApplicationName = '/LM/W3SVC/12345/ROOT'
>>> errors = ArrayList(); print log.GetErrors(0, 5, errors), len(errors)
44 5
>>> errors = ArrayList(); print log.GetErrors(0, 100, errors), len(errors)
Traceback (most recent call last):
SystemError: Unexpected end of file has occurred. The following elements are 
not 
closed:  Line 1, position 2034.

Original comment by azizatif on 9 May 2010 at 9:22

GoogleCodeExporter commented 9 years ago
Attached is an updated patch for ELMAH 1.1 and compiled .NET 2.0 binaries for 
testing and feedback. It should address this issue as well as the one from MS 
KB 
article Q310378.

Original comment by azizatif on 9 May 2010 at 9:42

Attachments:

GoogleCodeExporter commented 9 years ago
The latest patch fixed this issue for me!

Original comment by stuck...@gmail.com on 12 May 2010 at 12:45

GoogleCodeExporter commented 9 years ago
This is now being addressed in branch issue-129:
http://elmah.googlecode.com/svn/branches/issue-129/

Original comment by azizatif on 14 May 2010 at 6:05

GoogleCodeExporter commented 9 years ago
Fixed in r723.

Original comment by azizatif on 26 Sep 2010 at 8:38

GoogleCodeExporter commented 9 years ago
Issue 192 has been merged into this issue.

Original comment by azizatif on 27 Nov 2010 at 10:33

GoogleCodeExporter commented 9 years ago
Still issue in 1.2 SP2 it seems:

'', hexadecimal value 0x01, is an invalid character. Line 1, position 162.

Description: An unhandled exception occurred during the execution of the 
current web request. Please review the stack trace for more information about 
the error and where it originated in the code. 
Exception Details: System.Xml.XmlException: '', hexadecimal value 0x01, is an 
invalid character. Line 1, position 162.
Source Error:

An unhandled exception was generated during the execution of the current web 
request. Information regarding the origin and location of the exception can be 
identified using the exception stack trace below.
Stack Trace:

[XmlException: '', hexadecimal value 0x01, is an invalid character. Line 1, 
position 162.]
   System.Xml.XmlTextReaderImpl.Throw(Exception e) +95
   System.Xml.XmlTextReaderImpl.ThrowInvalidChar(Int32 pos, Char invChar) +259
   System.Xml.XmlTextReaderImpl.ParseNumericCharRefInline(Int32 startPos, Boolean expand, BufferBuilder internalSubsetBuilder, Int32& charCount, EntityType& entityType) +5115604
   System.Xml.XmlTextReaderImpl.ParseNumericCharRef(Boolean expand, BufferBuilder internalSubsetBuilder, EntityType& entityType) +84
   System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32& charRefEndPos) +273
   System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr) +615
   System.Xml.XmlTextReaderImpl.ParseAttributes() +916
   System.Xml.XmlTextReaderImpl.ParseElement() +378
   System.Xml.XmlTextReaderImpl.ParseDocumentContent() +429
   System.Xml.XmlReader.MoveToContent() +22
   System.Xml.XmlReader.IsStartElement(String name) +24
   Elmah.SqlErrorLog.ErrorsXmlToList(XmlReader reader, IList errorEntryList) +81
   Elmah.SqlErrorLog.GetErrors(Int32 pageIndex, Int32 pageSize, IList errorEntryList) +226
   Elmah.<>c__DisplayClass7.b__6() +36 Microsoft.SharePoint.<>c__DisplayClass4.b__2() +729 Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) +26824902 Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) +27879001 Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) +93 Elmah.SqlErrorLogWEP.GetErrors(Int32 pageIndex, Int32 pageSize, IList errorEntryList) +135 Elmah.ErrorLogPage.OnLoad(EventArgs e) +399 System.Web.UI.Control.LoadRecursive() +66 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428 

Original comment by cdenn...@gmail.com on 12 Jun 2014 at 4:57

GoogleCodeExporter commented 9 years ago
@cdenneen Can you post the offending XML (barring any details you want to 
remove, please) as an attachment here that can help to reproduce and identify 
the issue?

Original comment by azizatif on 12 Jun 2014 at 5:33