Standa Lukeš
4 years ago
4 changed files with 121 additions and 4 deletions
@ -0,0 +1,34 @@ |
|||||
|
{ |
||||
|
// Use IntelliSense to learn about possible attributes. |
||||
|
// Hover to view descriptions of existing attributes. |
||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 |
||||
|
"version": "0.2.0", |
||||
|
"configurations": [ |
||||
|
{ |
||||
|
"name": ".NET Core Launch (web)", |
||||
|
"type": "coreclr", |
||||
|
"request": "launch", |
||||
|
"preLaunchTask": "build", |
||||
|
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Ksp.WebServer.dll", |
||||
|
"args": [], |
||||
|
"cwd": "${workspaceFolder}", |
||||
|
"stopAtEntry": false, |
||||
|
"serverReadyAction": { |
||||
|
"action": "openExternally", |
||||
|
"pattern": "\\bNow listening on:\\s+(https?://\\S+)" |
||||
|
}, |
||||
|
"env": { |
||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
|
}, |
||||
|
"sourceFileMap": { |
||||
|
"/Views": "${workspaceFolder}/Views" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"name": ".NET Core Attach", |
||||
|
"type": "coreclr", |
||||
|
"request": "attach", |
||||
|
"processId": "${command:pickProcess}" |
||||
|
} |
||||
|
] |
||||
|
} |
@ -0,0 +1,42 @@ |
|||||
|
{ |
||||
|
"version": "2.0.0", |
||||
|
"tasks": [ |
||||
|
{ |
||||
|
"label": "build", |
||||
|
"command": "dotnet", |
||||
|
"type": "process", |
||||
|
"args": [ |
||||
|
"build", |
||||
|
"${workspaceFolder}/Ksp.WebServer.csproj", |
||||
|
"/property:GenerateFullPaths=true", |
||||
|
"/consoleloggerparameters:NoSummary" |
||||
|
], |
||||
|
"problemMatcher": "$msCompile" |
||||
|
}, |
||||
|
{ |
||||
|
"label": "publish", |
||||
|
"command": "dotnet", |
||||
|
"type": "process", |
||||
|
"args": [ |
||||
|
"publish", |
||||
|
"${workspaceFolder}/Ksp.WebServer.csproj", |
||||
|
"/property:GenerateFullPaths=true", |
||||
|
"/consoleloggerparameters:NoSummary" |
||||
|
], |
||||
|
"problemMatcher": "$msCompile" |
||||
|
}, |
||||
|
{ |
||||
|
"label": "watch", |
||||
|
"command": "dotnet", |
||||
|
"type": "process", |
||||
|
"args": [ |
||||
|
"watch", |
||||
|
"run", |
||||
|
"${workspaceFolder}/Ksp.WebServer.csproj", |
||||
|
"/property:GenerateFullPaths=true", |
||||
|
"/consoleloggerparameters:NoSummary" |
||||
|
], |
||||
|
"problemMatcher": "$msCompile" |
||||
|
} |
||||
|
] |
||||
|
} |
@ -0,0 +1,32 @@ |
|||||
|
using System.IO; |
||||
|
using AngleSharp.Html; |
||||
|
using Microsoft.AspNetCore.Http; |
||||
|
|
||||
|
namespace Ksp.WebServer |
||||
|
{ |
||||
|
public class KspPageRewriter |
||||
|
{ |
||||
|
public string RewriteHtml(string source, HttpContext context) |
||||
|
{ |
||||
|
var p = new AngleSharp.Html.Parser.HtmlParser(); |
||||
|
var document = p.ParseDocument(source); |
||||
|
|
||||
|
foreach (var form in document.QuerySelectorAll("form")) |
||||
|
{ |
||||
|
if (form.QuerySelector("input[type=password]") is null) |
||||
|
continue; |
||||
|
|
||||
|
var warning = document.CreateElement("div"); |
||||
|
warning.SetAttribute("style", "color: red; font-size: 3em; font-weight: bold"); |
||||
|
warning.TextContent = "Web běží na magické proxy, které byste měli věřit!!!"; |
||||
|
form.Prepend(warning); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
var outputHtml = new StringWriter(); |
||||
|
document.ToHtml(outputHtml, new PrettyMarkupFormatter() { Indentation = "\t", NewLine = "\n" }); |
||||
|
return outputHtml.ToString(); |
||||
|
} |
||||
|
} |
||||
|
} |
Reference in new issue