@@ -16,14 +16,20 @@ const LookupTable<ContentType, converters::Converter*> HttpInfo::CONVERTERS({
1616 { ContentType::FORM , new FormToJson () }
1717});
1818
19- HttpInfo::Content HttpInfo::getContent (const bool raw, const ContentType originalContentType, const std::string_view path, const std::string_view original) {
19+ HttpInfo::Content HttpInfo::getContent (const bool raw, const ContentType originalContentType, const std::string_view path, const std::string_view original, const bool censor ) {
2020 if (HttpInfo::CONVERTERS .contains (originalContentType)) {
2121 const converters::Converter* converter = HttpInfo::CONVERTERS .at (originalContentType);
2222
2323 if (!raw) {
24- return { converter->getResultContentType (), converter->convert (path, original) };
25- } else if (Mod::get ()->getSettingValue <bool >(" censor-data" ) && converter->isNeedsSanitization ()) {
26- return { originalContentType, converter->toRaw (path, converter->convert (path, original)) };
24+ return { converter->getResultContentType (), converter->convert (path, original, censor) };
25+ } else if (
26+ (
27+ (censor && Mod::get ()->getSettingValue <bool >(" censor-data" )) &&
28+ converter->isNeedsCensoring ()
29+ ) ||
30+ Mod::get ()->getSettingValue <bool >(" mask-telemetry" ) && converter->isNeedsMasking ()
31+ ) {
32+ return { originalContentType, converter->toRaw (path, converter->convert (path, original, censor)) };
2733 }
2834 }
2935
@@ -283,10 +289,9 @@ m_headers(HttpInfo::parseHeaderListStrings(HttpInfo::parseCocosHeaders(request->
283289m_body(std::string(request->getRequestData (), request->getRequestDataSize())),
284290m_contentType(HttpInfo::determineContentType(url.getPath(), true, m_body)),
285291m_startTime(Request::getRequestTime()) {
286- const size_t index = m_body.find (" dvs=" );
292+ if (Mod::get ()->getSettingValue <bool >(" mask-telemetry" )) {
293+ m_body = this ->getBodyContent (true , false ).contents ;
287294
288- if (index != std::string::npos) {
289- m_body.replace (index, 5 , " dvs=12" );
290295 request->setRequestData (m_body.c_str (), m_body.size ());
291296 }
292297}
@@ -315,8 +320,8 @@ std::vector<std::string> HttpInfo::Request::getHeader(const std::string_view key
315320 }
316321}
317322
318- HttpInfo::Content HttpInfo::Request::getBodyContent (const bool raw) const {
319- return HttpInfo::getContent (raw, m_contentType, m_path, m_body);
323+ HttpInfo::Content HttpInfo::Request::getBodyContent (const bool raw, const bool censor ) const {
324+ return HttpInfo::getContent (raw, m_contentType, m_path, m_body, censor );
320325}
321326
322327void HttpInfo::Request::resetTime () {
@@ -371,8 +376,8 @@ HttpInfo::Content HttpInfo::Response::getHeaderList(const bool raw) const {
371376 return HttpInfo::getHeaders (raw, m_headers);
372377}
373378
374- HttpInfo::Content HttpInfo::Response::getResponseContent (const bool raw) const {
375- return HttpInfo::getContent (raw, m_contentType, m_path, m_response);
379+ HttpInfo::Content HttpInfo::Response::getResponseContent (const bool raw, const bool censor ) const {
380+ return HttpInfo::getContent (raw, m_contentType, m_path, m_response, censor );
376381}
377382
378383std::vector<std::string> HttpInfo::Response::getHeader (const std::string_view key) const {
0 commit comments