private static void HtmlAttributeEncodeInternal(string value, HttpWriter writer) { int pos = IndexOfHtmlAttributeEncodingChars(value, 0); if (pos == -1) { writer.Write(value); return; } int cch = value.Length; int startPos = 0; for (; ;) { if (pos > startPos) { writer.WriteString(value, startPos, pos - startPos); } char ch = value[pos]; switch (ch) { case '"': writer.Write("""); break; case '\'': writer.Write("'"); break; case '&': writer.Write("&"); break; case '<': // Whidbey 32404: The character '<' is not valid in an XML attribute value. // (See the W3C XML rec). writer.Write("<"); break; } startPos = pos + 1; if (startPos >= cch) { break; } pos = IndexOfHtmlAttributeEncodingChars(value, startPos); if (pos == -1) { writer.WriteString(value, startPos, cch - startPos); break; } } }
public void NullWrites() { object null_object = null; string null_string = null; writer.Write(null_string); writer.Write(null_object); writer.WriteString(null, 0, 0); }
public void Methods_Deny_Unrestricted() { writer.Write(Char.MinValue); writer.Write(this); writer.Write(String.Empty); writer.Write(new char [1], 0, 1); writer.WriteLine(); writer.WriteString("mono", 0, 4); writer.WriteBytes(new byte[1], 0, 1); writer.Flush(); writer.Close(); }
public override void OnResultExecuted(ResultExecutedContext filterContext) { string response = _stringBuilder.ToString(); string version = ConfigurationManager.AppSettings.Get(Constants.STATIC_FILE_VERSION_KEY); string postfix = ConfigurationManager.AppSettings.Get(Constants.STATIC_FILE_POSTFIX_KEY); var updateModel = new UpdateModel() { InputString = response, FileExtension = ".js", TagAttribute = "src", StartPath = "/Scripts" }; updateModel.InputString = UpdatePostfix(updateModel, postfix, excludedScriptsForPostfix); updateModel.InputString = UpdateVersion(updateModel, version); updateModel.FileExtension = ".css"; updateModel.TagAttribute = "href"; updateModel.StartPath = "/Content"; updateModel.InputString = UpdatePostfix(updateModel, postfix, excludedCssPostfix); response = UpdateVersion(updateModel, version); _httpWriter.Write(response); }
/*** Public Part ***/ public override void OnResultExecuted(ResultExecutedContext filterContext) { string lResponse = _StringBuilder.ToString(); //response processing _HttpWriter.Write(lResponse); }
public override void OnResultExecuted(ResultExecutedContext filterContext) { string response = sb.ToString(); //response processing output.Write(response); }
private static void HtmlAttributeEncodeInternal(string value, HttpWriter writer) { int num = IndexOfHtmlAttributeEncodingChars(value, 0); if (num == -1) { writer.Write(value); return; } int length = value.Length; int index = 0; Label_001D: if (num > index) { writer.WriteString(value, index, num - index); } switch (value[num]) { case '&': writer.Write("&"); break; case '\'': writer.Write("'"); break; case '<': writer.Write("<"); break; case '"': writer.Write("""); break; } index = num + 1; if (index < length) { num = IndexOfHtmlAttributeEncodingChars(value, index); if (num != -1) { goto Label_001D; } writer.WriteString(value, index, length - index); } }
/// <summary> /// 执行html压缩 /// </summary> /// <param name="filterContext"></param> public override void OnResultExecuted(ResultExecutedContext filterContext) { if (EnableViewCompress) { string html = _sb.ToString(); if (filterContext.HttpContext.Response.ContentType == "text/html") { html = Regex.Replace(html, @"(?<=\s)\s+(?![^<>]*</pre>)", String.Empty); } _output.Write(html); } }
public override void OnResultExecuted(ResultExecutedContext filterContext) { var response = _stringBuilder.ToString(); // Change images to Amp-specific images response = UpdateAmpImages(response); // For AMP pages, change Script content to a link. response = ReplaceWithLink("script", response); // For AMP pages, change iFrame content to a link. response = ReplaceWithLink("iframe", response); _output.Write(response); }
/// <summary> /// 在执行完成后,处理得到的HTML,并将他输出到前台 /// </summary> /// <param name="filterContext"></param> protected override void OnResultExecuted(ResultExecutedContext filterContext) { string response = Replace(Compress(sb.ToString())); output.Write(response); }
public void OnResultExecuted(ResultExecutedContext filterContext) { if (filterContext.Exception != null) { return; } //生成的html try { string filename = filterContext.Controller.ViewData["FileName"].CastTo <string>(); bool IsCompress = (bool)filterContext.Controller.ViewData["IsCompress"]; string response = ""; if (IsCompress) { response = Compress(sb.ToString()); } else { response = sb.ToString(); } string _t = "html"; string _e = ".html"; string _f = filename + _e; string _dir = Path.Combine(MyPath.AppPath, _t); if (Directory.Exists(_dir) == false) { Directory.CreateDirectory(_dir); } string webUrl = "/" + _t + "/" + _f; string target_path = Path.Combine(MyPath.AppPath, _t, _f); IOHelper.WriteInfoToFile(response, target_path, Encoding.UTF8, false); ResultModel _result = null; if (File.Exists(target_path)) { _result = new ResultModel { msg = "重新生成", pass = true, append = new { url = webUrl } }; } else { _result = new ResultModel { msg = "创建成功", pass = true, append = new { url = webUrl } }; } string s = filterContext.HttpContext.Response.Status; filterContext.HttpContext.Response.ContentType = "application/json"; output.Write(JsonConvert.SerializeObject(_result)); filterContext.RequestContext.HttpContext.Response.Output = output; } catch (Exception e) { ResultModel _result = new ResultModel { msg = "创建失败," + e.Message, pass = false }; filterContext.HttpContext.Response.ContentType = "application/json"; output.Write(JsonConvert.SerializeObject(_result)); filterContext.RequestContext.HttpContext.Response.Output = output; } finally { if (sw != null) { sw.Dispose(); } if (tw != null) { tw.Dispose(); } } }