]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Implement recomendationm from #13050: step 1
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 21 Jul 2023 11:43:57 +0000 (13:43 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 22 Aug 2023 13:58:04 +0000 (15:58 +0200)
Revert #12660

(cherry picked from commit 26f5d6058d8b0cf4ad2f8da729cb906796c297a0)

ext/json11/json11.cpp
pdns/webserver.cc
regression-tests.api/test_Servers.py

index 77bf0d7174e50562f3571e64ec2f9fa4f5315633..a0ed9645da16e4b7fc3fe3c354f43c87951b5715 100644 (file)
@@ -93,10 +93,18 @@ static void dump(const string &value, string &out) {
             out += "\\r";
         } else if (ch == '\t') {
             out += "\\t";
-        } else if (static_cast<uint8_t>(ch) <= 0x1f || static_cast<uint8_t>(ch) >= 0x7f) {
+        } else if (static_cast<uint8_t>(ch) <= 0x1f) {
             char buf[8];
             snprintf(buf, sizeof buf, "\\u%04x", ch);
             out += buf;
+        } else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1]) == 0x80
+                   && static_cast<uint8_t>(value[i+2]) == 0xa8) {
+            out += "\\u2028";
+            i += 2;
+        } else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1]) == 0x80
+                   && static_cast<uint8_t>(value[i+2]) == 0xa9) {
+            out += "\\u2029";
+            i += 2;
         } else {
             out += ch;
         }
index 43cd180e8225f9c9d58eab8319bae173a2115284..f417561f3b364590d34968292e239e5cdc8a41a9 100644 (file)
@@ -535,7 +535,7 @@ void WebServer::serveConnection(const std::shared_ptr<Socket>& client) const {
   }
 
   if (d_loglevel >= WebServer::LogLevel::Normal) {
-    SLOG(g_log<<Logger::Notice<<logprefix<<remote<<" \""<<req.method<<" "<<YaHTTP::Utility::encodeURL(req.url.path)<<" HTTP/"<<req.versionStr(req.version)<<"\" "<<resp.status<<" "<<reply.size()<<endl,
+    SLOG(g_log<<Logger::Notice<<logprefix<<remote<<" \""<<req.method<<" "<<req.url.path<<" HTTP/"<<req.versionStr(req.version)<<"\" "<<resp.status<<" "<<reply.size()<<endl,
          d_slog->info(Logr::Info, "Request", "remote", Logging::Loggable(remote), "method", Logging::Loggable(req.method),
                       "urlpath", Logging::Loggable(req.url.path), "HTTPVersion", Logging::Loggable(req.versionStr(req.version)),
                       "status", Logging::Loggable(resp.status), "respsize",  Logging::Loggable(reply.size())));
index c9f59d19c1a030ad1d8efed2ad837f17c9a9bc62..47122ebb159387b1976471d9601166646b74d7c7 100644 (file)
@@ -2,7 +2,6 @@ import json
 import operator
 import requests
 import unittest
-import socket
 from test_helper import ApiTestCase, is_auth, is_recursor, is_auth_lmdb
 
 
@@ -42,18 +41,13 @@ class Servers(ApiTestCase):
         self.assertIn('daemon', data)
 
     def test_read_statistics(self):
-        # Use low-level API as we want to create an invalid request to test log line encoding
-        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM);
-        sock.connect((self.server_address, self.server_port))
-        sock.send(b'GET /binary\x00\x01\xeb HTTP/1.0\r\n')
-        sock.close()
         r = self.session.get(self.url("/api/v1/servers/localhost/statistics"))
         self.assert_success_json(r)
         data = r.json()
         self.assertIn('uptime', [e['name'] for e in data])
         print(data)
         if is_auth():
-            qtype_stats, respsize_stats, queries_stats, rcode_stats, logmessages = None, None, None, None, None
+            qtype_stats, respsize_stats, queries_stats, rcode_stats = None, None, None, None
             for elem in data:
                 if elem['type'] == 'MapStatisticItem' and elem['name'] == 'response-by-qtype':
                     qtype_stats = elem['value']
@@ -63,13 +57,10 @@ class Servers(ApiTestCase):
                     queries_stats = elem['value']
                 elif elem['type'] == 'MapStatisticItem' and elem['name'] == 'response-by-rcode':
                     rcode_stats = elem['value']
-                elif elem['type'] == 'RingStatisticItem' and elem['name'] == 'logmessages':
-                    logmessages = elem['value']
             self.assertIn('A', [e['name'] for e in qtype_stats])
             self.assertIn('80', [e['name'] for e in respsize_stats])
             self.assertIn('example.com/A', [e['name'] for e in queries_stats])
             self.assertIn('No Error', [e['name'] for e in rcode_stats])
-            self.assertTrue(logmessages[0]['name'].startswith('[webserver]'))
         else:
             qtype_stats, respsize_stats, rcode_stats = None, None, None
             for elem in data: