@@ -35,20 +35,24 @@ namespace uWS {
|
|||||||
bool compress;
|
bool compress;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Safari 15.0 - 15.3 has a completely broken compression implementation (client_no_context_takeover not
|
||||||
|
* properly implemented) - so we fully disable compression for this browser :-(
|
||||||
|
* see https://github.com/uNetworking/uWebSockets/issues/1347 */
|
||||||
inline bool hasBrokenCompression(std::string_view userAgent) {
|
inline bool hasBrokenCompression(std::string_view userAgent) {
|
||||||
size_t pos;
|
size_t posStart = userAgent.find(" Version/15.");
|
||||||
int uaVersion = 0;
|
if (posStart == std::string_view::npos) return false;
|
||||||
|
posStart += 12;
|
||||||
|
|
||||||
if ((pos = userAgent.find(" Version/")) == std::string_view::npos) return false;
|
size_t posEnd = userAgent.find(' ', posStart);
|
||||||
pos += 9;
|
if (posEnd == std::string_view::npos) return false;
|
||||||
|
|
||||||
std::string_view uaVersionStr = userAgent.substr(pos);
|
unsigned int minorVersion = 0;
|
||||||
uaVersionStr = uaVersionStr.substr(0, uaVersionStr.find_first_of(". "));
|
auto result = std::from_chars(userAgent.data() + posStart, userAgent.data() + posEnd, minorVersion);
|
||||||
auto result = std::from_chars(uaVersionStr.data(), uaVersionStr.data() + uaVersionStr.size(), uaVersion);
|
if (result.ec != std::errc()) return false;
|
||||||
if (result.ec == std::errc::invalid_argument) return false;
|
if (result.ptr != userAgent.data() + posEnd) return false; // do not accept trailing chars
|
||||||
if (uaVersion != 15) return false; // we target just Safari 15 - give Apple a chance ;-)
|
if (minorVersion > 3) return false; // we target just Safari 15.0 - 15.3
|
||||||
|
|
||||||
if ((pos = userAgent.find(" Safari/", pos)) == std::string_view::npos) return false;
|
if (userAgent.find(" Safari/", posEnd) == std::string_view::npos) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user