소스 검색

2004-09-03 Atsushi Enomoto <[email protected]>

	* XmlTextReader.cs : When Normalization is true, CRLF and CR should
	  be converted to single LF. This should fix part of bug #62076.

svn path=/trunk/mcs/; revision=33262
Atsushi Eno 21 년 전
부모
커밋
bf4435aed2
2개의 변경된 파일25개의 추가작업 그리고 4개의 파일을 삭제
  1. 5 0
      mcs/class/System.XML/System.Xml/ChangeLog
  2. 20 4
      mcs/class/System.XML/System.Xml/XmlTextReader.cs

+ 5 - 0
mcs/class/System.XML/System.Xml/ChangeLog

@@ -1,3 +1,8 @@
+2004-09-03  Atsushi Enomoto  <[email protected]>
+
+	* XmlTextReader.cs : When Normalization is true, CRLF and CR should
+	  be converted to single LF. This should fix part of bug #62076.
+
 2004-08-30  Atsushi Enomoto  <[email protected]>
 
 	* XmlWriter.cs : implemented WriteValue(object) for known types.

+ 20 - 4
mcs/class/System.XML/System.Xml/XmlTextReader.cs

@@ -1702,8 +1702,14 @@ namespace System.Xml
 					ch = ReadReference (false);
 					if (returnEntityReference) // Returns -1 if char validation should not be done
 						break;
-				}
-				else {
+				} else if (normalization && ch == '\r') {
+					ReadChar ();
+					ch = ReadChar ();
+					if (ch != '\n')
+						// append '\n' instead of '\r'.
+						AppendValueChar ('\n');
+					// and in case of "\r\n", discard '\r'.
+				} else {
 					if (XmlChar.IsInvalid (ch))
 						throw new XmlException (this, "Not allowed character was found.");
 					ch = ReadChar ();
@@ -2296,8 +2302,18 @@ namespace System.Xml
 						skip = true;
 					}
 				}
-				if (normalization && XmlChar.IsInvalid (ch))
-					throw new XmlException (this, "Invalid character was found.");
+				if (normalization) {
+					if (ch == '\r') {
+						ch = PeekChar ();
+						if (ch != '\n')
+							// append '\n' instead of '\r'.
+							AppendValueChar ('\n');
+						// otherwise, discard '\r'.
+						continue;
+					}
+					else if (XmlChar.IsInvalid (ch))
+						throw new XmlException (this, "Invalid character was found.");
+				}
 
 				AppendValueChar (ch);
 			}