-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix <img /> detection regex in web cmdlets #12099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3971046
4c25150
bb42b21
daec401
1792218
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,33 +29,38 @@ public string Index() | |
| } | ||
|
|
||
| StringValues dosLengths; | ||
| Int32 dosLength =1; | ||
| Int32 dosLength = 1; | ||
| if (Request.Query.TryGetValue("dosLength", out dosLengths)) | ||
| { | ||
| Int32.TryParse(dosLengths.FirstOrDefault(), out dosLength); | ||
| } | ||
|
|
||
| string body = string.Empty; | ||
| switch(dosType) | ||
| switch (dosType) | ||
| { | ||
| case "img": | ||
| contentType = "text/html; charset=utf8"; | ||
| body = "<img" + (new string(' ', dosLength)); | ||
| break; | ||
| // This is not really a DOS test, but this is the best place for it at present. | ||
| case "img-attribute": | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't actually a DOS... can you just add a comment explaining that?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TravisEz13 Yeah I was torn on that myself. I could also just add a new Controller class here instead, since we plan on adding future cases to test the actual regex patterns' capability to parse what we expect?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need to. I'll leave it up to you, but at least add a comment that this is not a DOS case, but you didn't want to create a new controller for a case that was so similar. |
||
| contentType = "text/html; charset=utf8"; | ||
| body = "<img src=\"https://fakesite.org/image.png\" id=\"mainImage\" class=\"lightbox\">"; | ||
| break; | ||
| case "charset": | ||
| contentType = "text/html; charset=melon"; | ||
| body = "<meta " + (new string('.', dosLength)); | ||
| break; | ||
| default: | ||
| throw new InvalidOperationException("Invalid dosType: "+dosType); | ||
| throw new InvalidOperationException("Invalid dosType: " + dosType); | ||
| } | ||
|
|
||
| // Content-Type must be applied right before it is sent to the client or MVC will overwrite. | ||
| Response.OnStarting(state => | ||
| { | ||
| var httpContext = (HttpContext) state; | ||
| httpContext.Response.ContentType = contentType; | ||
| return Task.FromResult(0); | ||
| var httpContext = (HttpContext)state; | ||
| httpContext.Response.ContentType = contentType; | ||
| return Task.FromResult(0); | ||
| }, HttpContext); | ||
|
|
||
| Response.ContentLength = Encoding.UTF8.GetBytes(body).Length; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.