private string PreprocessScript(string input, string tag_name) { StringBuilder stringBuilder1 = new StringBuilder(); int startIndex = 0; int length = tag_name.Length; while (startIndex < input.Length) { bool flag = false; if (startIndex + length + 1 < input.Length && input.Substring(startIndex, length + 1).ToLower().Equals("<" + tag_name)) { while (true) { if (startIndex < input.Length) { if (!input.Substring(startIndex, 1).Equals(">")) { if (startIndex + 1 >= input.Length || !input.Substring(startIndex, 2).Equals("/>")) { if (input.Substring(startIndex, 1).Equals("\"")) { stringBuilder1.Append("\""); for (++startIndex; startIndex < input.Length && !input.Substring(startIndex, 1).Equals("\""); ++startIndex) { stringBuilder1.Append(input.Substring(startIndex, 1)); } if (startIndex < input.Length) { ++startIndex; stringBuilder1.Append("\""); } } else if (input.Substring(startIndex, 1).Equals("'")) { stringBuilder1.Append("'"); for (++startIndex; startIndex < input.Length && !input.Substring(startIndex, 1).Equals("'"); ++startIndex) { stringBuilder1.Append(input.Substring(startIndex, 1)); } if (startIndex < input.Length) { ++startIndex; stringBuilder1.Append("'"); } } else { stringBuilder1.Append(input.Substring(startIndex, 1)); ++startIndex; } } else { goto label_5; } } else { break; } } else { goto label_21; } } stringBuilder1.Append(">"); ++startIndex; goto label_21; label_5: stringBuilder1.Append("/>"); startIndex += 2; flag = true; label_21: if (startIndex < input.Length) { if (!flag) { StringBuilder stringBuilder2 = new StringBuilder(); for (; startIndex + length + 3 < input.Length && !input.Substring(startIndex, length + 3).ToLower().Equals("</" + tag_name + ">"); ++startIndex) { stringBuilder2.Append(input.Substring(startIndex, 1)); } stringBuilder1.Append(HtmlParser.EncodeScript(stringBuilder2.ToString())); stringBuilder1.Append("</" + tag_name + ">"); if (startIndex + length + 3 < input.Length) { startIndex += length + 3; } } } else { break; } } else { stringBuilder1.Append(input.Substring(startIndex, 1)); ++startIndex; } } return(stringBuilder1.ToString()); }
private string PreprocessScript(string input, string tag_name) { StringBuilder stringBuilder = new StringBuilder(); int i = 0; int length = tag_name.Length; while (i < input.Length) { bool flag = false; if (i + length + 1 < input.Length && input.Substring(i, length + 1).ToLower().Equals("<" + tag_name)) { while (i < input.Length) { if (input.Substring(i, 1).Equals(">")) { stringBuilder.Append(">"); i++; } else { if (i + 1 >= input.Length || !input.Substring(i, 2).Equals("/>")) { if (input.Substring(i, 1).Equals("\"")) { stringBuilder.Append("\""); i++; while (i < input.Length && !input.Substring(i, 1).Equals("\"")) { stringBuilder.Append(input.Substring(i, 1)); i++; } if (i < input.Length) { i++; stringBuilder.Append("\""); } } else if (input.Substring(i, 1).Equals("'")) { stringBuilder.Append("'"); i++; while (i < input.Length && !input.Substring(i, 1).Equals("'")) { stringBuilder.Append(input.Substring(i, 1)); i++; } if (i < input.Length) { i++; stringBuilder.Append("'"); } } else { stringBuilder.Append(input.Substring(i, 1)); i++; } continue; } stringBuilder.Append("/>"); i += 2; flag = true; } break; } if (i >= input.Length) { goto IL_314; } if (!flag) { StringBuilder stringBuilder2 = new StringBuilder(); while (i + length + 3 < input.Length && !input.Substring(i, length + 3).ToLower().Equals("</" + tag_name + ">")) { stringBuilder2.Append(input.Substring(i, 1)); i++; } stringBuilder.Append(HtmlParser.EncodeScript(stringBuilder2.ToString())); stringBuilder.Append("</" + tag_name + ">"); if (i + length + 3 < input.Length) { i += length + 3; } } goto IL_301; } stringBuilder.Append(input.Substring(i, 1)); i++; IL_301 :; } IL_314 : return(stringBuilder.ToString()); }