Browse Source

www: set an explicit security policy for fetch documents

Not really important for MAX80, but these may be useful to have
elsewhere.
H. Peter Anvin 2 years ago
parent
commit
6fb1bca17d
4 changed files with 5 additions and 3 deletions
  1. BIN
      esp32/output/max80.ino.bin
  2. 5 3
      esp32/www/max80.js
  3. BIN
      fpga/output/v1.fw
  4. BIN
      fpga/output/v2.fw

BIN
esp32/output/max80.ino.bin


+ 5 - 3
esp32/www/max80.js

@@ -1,4 +1,6 @@
 const PassiveListener = { passive: true };
+const LocalGet        = { method: 'GET', mode: 'same-origin',
+			  redirect: 'follow' };
 
 // Get an element by id or an Element object
 function getelem(id) {
@@ -22,10 +24,10 @@ function classmod(elem,tags) {
 
 // Read a key=value text file and return it as a Promise of a Map
 function fetchconfig(url) {
-    return fetch(url, {redirect: "follow"})
+    return fetch(url, LocalGet)
 	.then(res => {
 	    if (!res.ok) {
-		throw new Error("HTTP error "+response.status);
+		throw new Error('HTTP error '+response.status);
 	    } else {
 		return res.text();
 	    }
@@ -239,7 +241,7 @@ fetchconfig('/sys/lang')
 class IncHTML extends HTMLElement {
     constructor() { self = super(); }
     connectedCallback() {
-	fetch(self.getAttribute('src'))
+	fetch(self.getAttribute('src'), LocalGet)
 	    .then ((r) => r.text())
 	    .then ((text) => {
 		const p = self.parentElement;

BIN
fpga/output/v1.fw


BIN
fpga/output/v2.fw