Browse Source

2004-05-06 Gonzalo Paniagua Javier <[email protected]>

	* AspParser.cs: indent a few lines.
	* AspTokenizer.cs: added ungetc() used when we read a '/' in an unquoted
	attribute value. This way we can simulate reading 2 characters ahead
	(one in ungetc and the other in Peek) and work with values like
	text/javascript. Fixes bug #57302.

svn path=/trunk/mcs/; revision=26798
Gonzalo Paniagua Javier 21 years ago
parent
commit
c2cf85f5fa

+ 13 - 13
mcs/class/System.Web/System.Web.Compilation/AspParser.cs

@@ -253,19 +253,19 @@ namespace System.Web.Compilation
 					tokenizer.InTag = false;
 					id = "<" + tokenizer.Odds + tokenizer.Value;
 				} else {
-				id = tokenizer.Value;
-				try {
-					attributes = GetAttributes ();
-				} catch (Exception e) {
-					OnError (e.Message);
-					break;
-				}
-				
-				tagtype = TagType.Tag;
-				if (Eat ('/') && Eat ('>'))
-					tagtype = TagType.SelfClosing;
-				else if (!Eat ('>'))
-					OnError ("expecting '>'. Got '" + tokenizer.Value + "'");
+					id = tokenizer.Value;
+					try {
+						attributes = GetAttributes ();
+					} catch (Exception e) {
+						OnError (e.Message);
+						break;
+					}
+					
+					tagtype = TagType.Tag;
+					if (Eat ('/') && Eat ('>'))
+						tagtype = TagType.SelfClosing;
+					else if (!Eat ('>'))
+						OnError ("expecting '>'. Got '" + tokenizer.Value + "'");
 				}
 
 				break;

+ 30 - 2
mcs/class/System.Web/System.Web.Compilation/AspTokenizer.cs

@@ -37,6 +37,8 @@ namespace System.Web.Compilation
 		bool hasPutBack;
 		bool verbatim;
 		bool have_value;
+		bool have_unget;
+		int unget_value;
 		string val;
 		
 		public AspTokenizer (TextReader reader)
@@ -88,9 +90,26 @@ namespace System.Web.Compilation
 			return (Char.IsLetterOrDigit (c) || c == '_' || c == '-');
 		}
 
+		void ungetc (int value)
+		{
+			have_unget = true;
+			unget_value = value;
+
+			// Only '/' passes through here now.
+			// If we ever let \n here, update 'line'
+			position--;
+			col--;
+		}
+		
 		int read_char ()
 		{
-			int c = sr.Read ();
+			int c;
+			if (have_unget) {
+				c = unget_value;
+				have_unget = false;
+			} else {
+				c = sr.Read ();
+			}
 
 			if (c == '\r' && sr.Peek () == '\n') {
 				c = sr.Read ();
@@ -132,7 +151,16 @@ namespace System.Web.Compilation
 				} else if (inServerTag && c == '>' && last == '%') {
 					inServerTag = false;
 				} else if (!inServerTag) {
-					if (!quoted && (c == '/' || c == '>' || Char.IsWhiteSpace ((char) c))) {
+					if (!quoted && c == '/') {
+						read_char ();
+						c = sr.Peek ();
+						if (c == -1) {
+							c = '/';
+						} else if (c == '>') {
+							ungetc ('/');
+							break;
+						}
+					} else if (!quoted && (c == '>' || Char.IsWhiteSpace ((char) c))) {
 						break;
 					} else if (quoted && c == quoteChar && last != '\\') {
 						read_char ();

+ 8 - 0
mcs/class/System.Web/System.Web.Compilation/ChangeLog

@@ -1,3 +1,11 @@
+2004-05-06  Gonzalo Paniagua Javier <[email protected]>
+
+	* AspParser.cs: indent a few lines.
+	* AspTokenizer.cs: added ungetc() used when we read a '/' in an unquoted
+	attribute value. This way we can simulate reading 2 characters ahead
+	(one in ungetc and the other in Peek) and work with values like
+	text/javascript. Fixes bug #57302.
+
 2004-05-06  Gonzalo Paniagua Javier <[email protected]>
 
 	* AspParser.cs: ignore whitespace after directives. Fixes bug #58057.