Compare domains in lowercase

Domains are case-insensitive, so this comparision should be too.

I encountered this issue with a Citadel user who accidentially named their domain an uppercase name (Pay.example.com), but browsers automatically converted it to pay.example.com
This commit is contained in:
Aaron Dewes 2023-07-02 19:58:11 +02:00 committed by Andrew Camilleri
parent f3dbf1e139
commit f6b27cc5f9

View file

@ -17,7 +17,7 @@
notificationDisabled = user?.DisabledNotifications == "all";
}
var expectedScheme = _context.HttpContext.Request.Scheme;
var expectedHost = _context.HttpContext.Request.Host.ToString();
var expectedHost = _context.HttpContext.Request.Host.ToString().ToLower();
}
<!DOCTYPE html>
@ -79,7 +79,7 @@
{
<script>
var mainContent = document.getElementById("mainContent");
if (window.location.protocol != "@(expectedScheme):" || window.location.host != "@expectedHost")
if (window.location.protocol != "@(expectedScheme):" || window.location.host.toLowerCase() != "@expectedHost")
{
var tmpl = document.getElementById("badUrl");
mainContent.prepend(tmpl.content.cloneNode(true));