public void GetExtension() { Assert.AreEqual(".aspx", VPU.GetExtension("/hi/index.aspx"), "A1"); Assert.AreEqual("", VPU.GetExtension("/hi/index.aspx/"), "A1"); Assert.AreEqual(".aspx", VPU.GetExtension("index.aspx"), "A2"); Assert.AreEqual("", VPU.GetExtension("/hi/index"), "A3"); Assert.AreEqual(".aspx", VPU.GetExtension("/hi/./index.aspx"), "A1"); Assert.AreEqual("", VPU.GetExtension("hi/index"), "A2"); Assert.AreEqual("", VPU.GetExtension("/hi/index.aspx/file"), "A1"); Assert.AreEqual("", VPU.GetExtension("/hi/index.aspx\\file"), "A1"); Assert.AreEqual("", VPU.GetExtension("/hi/index.aspx/../file"), "A1"); Assert.AreEqual(".htm", VPU.GetExtension("/hi/index.aspx/../file.htm"), "A1"); Assert.AreEqual("", VPU.GetExtension(".."), "A2"); Assert.AreEqual("", VPU.GetExtension("../.."), "A2"); Assert.AreEqual(".aspx", VPU.GetExtension("../../file.aspx"), "A2"); }
public virtual IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback callback, object state) { this.Context = context; HttpRequest req = context != null ? context.Request : null; string filePath = req != null ? req.FilePath : null; if (!String.IsNullOrEmpty(filePath) && String.Compare(".asp", VirtualPathUtility.GetExtension(filePath), StringComparison.OrdinalIgnoreCase) == 0) { throw new HttpException(String.Format("Access to file '{0}' is forbidden.", filePath)); } if (req != null && String.Compare("POST", req.HttpMethod, StringComparison.OrdinalIgnoreCase) == 0) { throw new HttpException(String.Format("Method '{0}' is not allowed when accessing file '{1}'", req.HttpMethod, filePath)); } var sfh = new StaticFileHandler(); sfh.ProcessRequest(context); return(new DefaultHandlerAsyncResult(callback, state)); }
public void GetExtension3() { Assert.AreEqual("", VPU.GetExtension("/direc/somefilenoextension")); Assert.AreEqual("", VPU.GetExtension("/")); Assert.AreEqual("/direc/", VPU.GetDirectory("/////direc///somefile.aspx")); }
public void GetExtension2() { // Amazing. VPU.GetExtension(""); }
public void GetExtension1() { VPU.GetExtension(null); }