Sfoglia il codice sorgente

www: fix CSS :lang() syntax for Chrome

Chrome is more picky than Firefox: Chrome does not accept :lang("en")
instead of :lang(en). Do the latter, but also validate that the string
doesn't contain invalid characters.
H. Peter Anvin 2 anni fa
parent
commit
48b93413df

+ 1 - 0
esp32/max80/httpd.c

@@ -521,6 +521,7 @@ static const struct mime_type mime_types[] = {
     { ".xml",   4, MT_CHARSET, "text/xml"                  },
     { ".bin",   4, 0,          "application/octet-stream"  },
     { ".fw",    3, 0,          "application/octet-stream"  },
+    { ".capt",  5, 0,          "application/captive+json"  },
     { "_redir", 6, MT_REDIR,   NULL                        },
     { NULL,     0, MT_CHARSET, "text/plain"                }  /* default */
 };

+ 5 - 2
esp32/max80/src/dhcpserver.c

@@ -108,7 +108,8 @@ static dhcps_offer_t dhcps_offer = 0xFF;
 static dhcps_offer_t dhcps_dns = 0x00;
 static dhcps_cb_t dhcps_cb;
 
-#define DHCPS_CAPTIVE_PORTAL 1	/* 0 = off, 1 = new only, 2 = old + new */
+#define DHCPS_CAPTIVE_PORTAL   1 /* 0 = off, 1 = new only, 2 = old + new */
+#define DHCPS_CAPTIVE_API_URL "/portal.capt"
 
 /******************************************************************************
  * FunctionName : dhcps_option_info
@@ -392,7 +393,9 @@ static u8_t *add_offer_options(u8_t *optptr)
 
     for (i = 0; i < DHCPS_CAPTIVE_PORTAL; i++) {
 	optptr[0] = i ? CAPTIVE_PORTAL_OLD : CAPTIVE_PORTAL;
-	optptr[1] = snprintf(optptr+2, 256, "http://%u.%u.%u.%u/",
+	optptr[1] = snprintf(optptr+2, 256,
+			     "http://%u.%u.%u.%u"
+			     DHCPS_CAPTIVE_API_URL,
 			     ip4_addr1(&ipadd), ip4_addr2(&ipadd),
 			     ip4_addr3(&ipadd), ip4_addr4(&ipadd));
 	optptr += optptr[1] + 2;

BIN
esp32/output/max80.ino.bin


+ 2 - 1
esp32/www/max80.js

@@ -219,9 +219,10 @@ var lang_styleobj = document.createElement('style');
 document.head.append(lang_styleobj);
 function setlang(l = null) {
     l = l || document.documentElement.lang;
+    if (!l.match(/^\w+(?:-\w+)*$/)) return; // Invalid language tag
     var sty = lang_styleobj.sheet;
     while (sty.rules.length) sty.deleteRule(0);
-    sty.insertRule('[lang]:not(:lang("'+l+'")):not(:last-child),[lang]:lang("'+l+'")~[lang] {display: none}', 0);
+    sty.insertRule('[lang]:not(:lang('+l+')):not(:last-child),[lang]:lang('+l+')~[lang] {display: none}', 0);
     document.documentElement.lang = l;
 }
 setlang();

BIN
fpga/output/v1.fw


BIN
fpga/output/v2.fw