From 2fd034d1df36e9d47995d3eddc290d4c5652d538 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 24 Jan 2024 15:25:24 -0500 Subject: [PATCH] LibWebView: Prevent quoting attribute values twice in the Inspector As of commit ccd701809fc168c90b2f74bdb3b3f2a3fd82d10e, the formatter for JsonValue now fully serializes the value. The serializer will surround the string value with quotes. We want control over when we add quotes to the generated Inspector HTML, so avoid formatting attributes as raw JSON values. --- Userland/Libraries/LibWebView/InspectorClient.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWebView/InspectorClient.cpp b/Userland/Libraries/LibWebView/InspectorClient.cpp index 97def360e3..28ef546355 100644 --- a/Userland/Libraries/LibWebView/InspectorClient.cpp +++ b/Userland/Libraries/LibWebView/InspectorClient.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Tim Flynn + * Copyright (c) 2023-2024, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -523,11 +523,13 @@ String InspectorClient::generate_dom_tree(JsonObject const& dom_tree) if (auto attributes = node.get_object("attributes"sv); attributes.has_value()) { attributes->for_each_member([&](auto const& name, auto const& value) { + auto value_string = value.as_string(); + builder.append(" "sv); - builder.appendff("", tag, name, value); + builder.appendff("", tag, name, value_string); builder.appendff("{}", name); builder.append('='); - builder.appendff("\"{}\"", value); + builder.appendff("\"{}\"", value_string); builder.append(""sv); }); }