366 {
367 std::string safe_host;
368 for (char c : host) {
369 if (c == '<') safe_host += "<";
370 else if (c == '>') safe_host += ">";
371 else if (c == '&') safe_host += "&";
372 else if (c == '"') safe_host += """;
373 else safe_host += c;
374 }
375
376 const std::string html =
377 "<!DOCTYPE html><html><head><meta charset='UTF-8'>"
378 "<style>"
379 "body{margin:0;height:100vh;display:flex;align-items:center;"
380 "justify-content:center;background:#1a1a2e;font-family:system-ui,sans-serif;}"
381 ".card{background:#16213e;border:1px solid #0f3460;border-radius:12px;"
382 "padding:40px 36px;max-width:460px;text-align:center;color:#e0e0e0;}"
383 "h1{color:#e94560;font-size:1.3rem;margin:0 0 16px;}"
384 "p{color:#a0a0b0;font-size:.9rem;line-height:1.6;margin:0 0 24px;}"
385 ".domain{font-family:monospace;color:#4fc3f7;background:#0d1b2a;"
386 "padding:4px 10px;border-radius:4px;}"
387 "button{background:#0f3460;color:#fff;border:none;border-radius:8px;"
388 "padding:10px 24px;font-size:.9rem;cursor:pointer;}"
389 "button:hover{background:#1a4a80;}"
390 "</style></head><body>"
391 "<div class='card'>"
392 "<h1>🛡️ BastionGuard — Navigazione bloccata</h1>"
393 "<p>Il dominio <span class='domain'>" + safe_host + "</span> "
394 "non è accessibile dalla sessione sicura.<br><br>"
395 "Chiudi questa finestra e aprilo nel tuo browser normale.</p>"
396 "<button onclick='window.close()'>Chiudi</button>"
397 "</div></body></html>";
398
399 std::string encoded;
400 for (unsigned char c : html) {
401 if (std::isalnum(c) || c == '-' || c == '_' || c == '.' ||
402 c == '!' || c == '~' || c == '*' || c == '\'' ||
403 c == '(' || c == ')') {
404 encoded += static_cast<char>(c);
405 } else {
406 char buf[4];
407 std::snprintf(buf, sizeof(buf), "%%%02X", c);
408 encoded += buf;
409 }
410 }
411
412 if (browser && browser->GetMainFrame())
413 browser->GetMainFrame()->LoadURL("data:text/html," + encoded);
414 }