security fix, simple-http-server fix

This commit is contained in:
Anton-4 2025-03-21 17:49:41 +01:00
parent 4fb5c42055
commit a4ae083b60
No known key found for this signature in database
GPG key ID: 0971D718C0A9B937
4 changed files with 33 additions and 11 deletions

View file

@ -97,6 +97,7 @@
zls # zig language server
watchexec
simple-http-server # to view the website locally
]);
aliases = ''

View file

@ -1,6 +1,6 @@
{ rustPlatform, fetchFromGitHub }:
{ rustPlatform, fetchFromGitHub, pkg-config, openssl }:
rustPlatform.buildRustPackage {
rustPlatform.buildRustPackage rec {
pname = "simple-http-server";
version = "0.1.0"; # adjust version as needed
@ -8,9 +8,15 @@ rustPlatform.buildRustPackage {
owner = "Anton-4";
repo = "simple-http-server";
rev = "f3089e5736a1e8abdb69ba9e7618fe5e518a2df0";
sha256 = "sha256-Vcckv75hmJV7F9mqPtM3piSIZg9MvKI/oU7/tv4viy4=";
};
cargoLock = {
lockFile = "${src}/Cargo.lock";
};
nativeBuildInputs = [ pkg-config ];
buildInputs =
[ openssl ];
}

View file

@ -20,6 +20,8 @@ bash ./www/build-dev-local.sh
Open http://0.0.0.0:8080 in your browser.
If you want to build the repl as well, check out crates/repl_wasm/README.md.
## After you've made a change locally
In the terminal where the web server is running:

View file

@ -351,18 +351,31 @@ function createHistoryEntry(inputText) {
const historyIndex = repl.inputHistory.length;
repl.inputHistory.push(inputText);
const firstLinePrefix = '<span class="input-line-prefix">» </span>';
const otherLinePrefix = '<br><span class="input-line-prefix">… </span>';
const inputLines = inputText.split("\n");
if (inputLines[inputLines.length - 1] === "") {
inputLines.pop();
}
const inputWithPrefixes = firstLinePrefix + inputLines.join(otherLinePrefix);
const inputElem = document.createElement("div");
inputElem.innerHTML = inputWithPrefixes;
inputElem.classList.add("input");
const inputLines = inputText.split("\n").filter(line => line !== ""); // Remove empty last line if present
inputLines.forEach((line, index) => {
if (index > 0) {
// Add line break for subsequent lines
inputElem.appendChild(document.createElement("br"));
const prefixSpan = document.createElement("span");
prefixSpan.className = "input-line-prefix";
prefixSpan.textContent = "… ";
inputElem.appendChild(prefixSpan);
} else {
// First line prefix
const prefixSpan = document.createElement("span");
prefixSpan.className = "input-line-prefix";
prefixSpan.textContent = "» ";
inputElem.appendChild(prefixSpan);
}
// Add the line text as plain text
inputElem.appendChild(document.createTextNode(line));
});
const historyItem = document.createElement("div");
historyItem.appendChild(inputElem);
historyItem.classList.add("history-item");