Loading src/blogi.cpp +38 −4 Changes for src/blogi.cpp: 38 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -88,12 +88,46 @@ static std::string cookieDomain(libhttppp::HttpRequest &req) { h = fwd->at(0).getvalue(); else h = req.getHost(); // x-forwarded-host may contain a comma-separated chain; use first host. auto comma = h.find(','); if (comma != std::string::npos) h = h.substr(0, comma); auto trim = [](std::string &s) { auto first = s.find_first_not_of(" \t\r\n"); if (first == std::string::npos) { s.clear(); return; } auto last = s.find_last_not_of(" \t\r\n"); s = s.substr(first, last - first + 1); }; trim(h); if (h.empty()) return std::string(); // Strip port if present // Handle bracketed IPv6 host notation: [::1]:8080 if (!h.empty() && h.front() == '[') { auto close = h.find(']'); if (close != std::string::npos) h = h.substr(1, close - 1); } else { // Strip port for regular hostnames/IPv4. auto colon = h.find(':'); if (colon != std::string::npos) h = h.substr(0, colon); // Don't set parent domain for IP addresses if (netplus::isIPAddr(h)) return h; if (colon != std::string::npos) h = h.substr(0, colon); } trim(h); std::transform(h.begin(), h.end(), h.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); }); // For localhost/IP/single-label hosts use host-only cookies (no Domain attribute). if (h == "localhost") return std::string(); if (netplus::isIPAddr(h)) return std::string(); if (h.find('.') == std::string::npos) return std::string(); // Find parent domain (at least two labels required) auto dot = h.find('.'); if (dot != std::string::npos && dot + 1 < h.size()) { Loading Loading
src/blogi.cpp +38 −4 Changes for src/blogi.cpp: 38 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -88,12 +88,46 @@ static std::string cookieDomain(libhttppp::HttpRequest &req) { h = fwd->at(0).getvalue(); else h = req.getHost(); // x-forwarded-host may contain a comma-separated chain; use first host. auto comma = h.find(','); if (comma != std::string::npos) h = h.substr(0, comma); auto trim = [](std::string &s) { auto first = s.find_first_not_of(" \t\r\n"); if (first == std::string::npos) { s.clear(); return; } auto last = s.find_last_not_of(" \t\r\n"); s = s.substr(first, last - first + 1); }; trim(h); if (h.empty()) return std::string(); // Strip port if present // Handle bracketed IPv6 host notation: [::1]:8080 if (!h.empty() && h.front() == '[') { auto close = h.find(']'); if (close != std::string::npos) h = h.substr(1, close - 1); } else { // Strip port for regular hostnames/IPv4. auto colon = h.find(':'); if (colon != std::string::npos) h = h.substr(0, colon); // Don't set parent domain for IP addresses if (netplus::isIPAddr(h)) return h; if (colon != std::string::npos) h = h.substr(0, colon); } trim(h); std::transform(h.begin(), h.end(), h.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); }); // For localhost/IP/single-label hosts use host-only cookies (no Domain attribute). if (h == "localhost") return std::string(); if (netplus::isIPAddr(h)) return std::string(); if (h.find('.') == std::string::npos) return std::string(); // Find parent domain (at least two labels required) auto dot = h.find('.'); if (dot != std::string::npos && dot + 1 < h.size()) { Loading