diff --git a/src/jsc/bindings/bindings.cpp b/src/jsc/bindings/bindings.cpp index c866dd1d387c..bb3db646c96a 100644 --- a/src/jsc/bindings/bindings.cpp +++ b/src/jsc/bindings/bindings.cpp @@ -3438,12 +3438,6 @@ JSC::EncodedJSValue ZigString__toRangeErrorInstance(const ZigString* str, JSC::J return JSC::JSValue::encode(Zig::getRangeErrorInstance(str, globalObject)); } -static JSC::EncodedJSValue resolverFunctionCallback(JSC::JSGlobalObject* globalObject, - JSC::CallFrame* callFrame) -{ - return JSC::JSValue::encode(JSC::jsUndefined()); -} - JSC::JSPromise* JSC__JSModuleLoader__loadAndEvaluateModule(JSC::JSGlobalObject* globalObject, const BunString* arg1) diff --git a/src/jsc/bindings/webcore/HTTPParsers.cpp b/src/jsc/bindings/webcore/HTTPParsers.cpp index 19bd1c5868b4..1f0287892db1 100644 --- a/src/jsc/bindings/webcore/HTTPParsers.cpp +++ b/src/jsc/bindings/webcore/HTTPParsers.cpp @@ -169,18 +169,6 @@ bool isValidAcceptHeaderValue(const StringView& value) return true; } -static bool containsCORSUnsafeRequestHeaderBytes(const String& value) -{ - for (unsigned i = 0; i < value.length(); ++i) { - char16_t c = value[i]; - // https://fetch.spec.whatwg.org/#cors-unsafe-request-header-byte - if ((c < 0x20 && c != '\t') || (c == '"' || c == '(' || c == ')' || c == ':' || c == '<' || c == '>' || c == '?' || c == '@' || c == '[' || c == '\\' || c == ']' || c == 0x7B || c == '{' || c == '}' || c == 0x7F)) - return true; - } - - return false; -} - // See RFC 7231, Section 5.3.5 and 3.1.3.2. // https://fetch.spec.whatwg.org/#cors-safelisted-request-header bool isValidLanguageHeaderValue(const StringView& value) diff --git a/src/jsc/bindings/webcore/HeaderFieldTokenizer.cpp b/src/jsc/bindings/webcore/HeaderFieldTokenizer.cpp deleted file mode 100644 index c0134438fd93..000000000000 --- a/src/jsc/bindings/webcore/HeaderFieldTokenizer.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2017 The Chromium Authors. All rights reserved. - * Copyright (C) 2018 Akamai Technologies Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "HeaderFieldTokenizer.h" - -#include "RFC7230.h" -#include - -namespace WebCore { - -HeaderFieldTokenizer::HeaderFieldTokenizer(const String& headerField) - : m_input(headerField) -{ - skipSpaces(); -} - -bool HeaderFieldTokenizer::consume(char16_t c) -{ - ASSERT(!isTabOrSpace(c)); - - if (isConsumed() || m_input[m_index] != c) - return false; - - ++m_index; - skipSpaces(); - return true; -} - -String HeaderFieldTokenizer::consumeQuotedString() -{ - StringBuilder builder; - - ASSERT(m_input[m_index] == '"'); - ++m_index; - - while (!isConsumed()) { - if (m_input[m_index] == '"') { - String output = builder.toString(); - ++m_index; - skipSpaces(); - return output; - } - if (m_input[m_index] == '\\') { - ++m_index; - if (isConsumed()) - return String(); - } - builder.append(m_input[m_index]); - ++m_index; - } - return String(); -} - -String HeaderFieldTokenizer::consumeToken() -{ - auto start = m_index; - while (!isConsumed() && RFC7230::isTokenCharacter(m_input[m_index])) - ++m_index; - - if (start == m_index) - return String(); - - String output = m_input.substring(start, m_index - start); - skipSpaces(); - return output; -} - -String HeaderFieldTokenizer::consumeTokenOrQuotedString() -{ - if (isConsumed()) - return String(); - - if (m_input[m_index] == '"') - return consumeQuotedString(); - - return consumeToken(); -} - -void HeaderFieldTokenizer::skipSpaces() -{ - while (!isConsumed() && isTabOrSpace(m_input[m_index])) - ++m_index; -} - -void HeaderFieldTokenizer::consumeBeforeAnyCharMatch(const Vector& chars) -{ - ASSERT(chars.size() > 0U && chars.size() < 3U); - - while (!isConsumed()) { - for (const auto& c : chars) { - if (c == m_input[m_index]) - return; - } - - ++m_index; - } -} - -} // namespace WebCore diff --git a/src/jsc/bindings/webcore/HeaderFieldTokenizer.h b/src/jsc/bindings/webcore/HeaderFieldTokenizer.h deleted file mode 100644 index f05049c8781d..000000000000 --- a/src/jsc/bindings/webcore/HeaderFieldTokenizer.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2017 The Chromium Authors. All rights reserved. - * Copyright (C) 2018 Akamai Technologies Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include - -namespace WebCore { - -// Parses header fields into tokens, quoted strings and separators. -// Commonly used by ParsedContent* classes. -class HeaderFieldTokenizer { - -public: - explicit HeaderFieldTokenizer(const String&); - - // Try to parse a separator character, a token or either a token or a quoted - // string from the |header_field| input. Return |true| on success. Return - // |false| if the separator character, the token or the quoted string is - // missing or invalid. - bool consume(char16_t); - String consumeToken(); - String consumeTokenOrQuotedString(); - - // Consume all characters before (but excluding) any of the characters from - // the Vector parameter are found. - // Because we potentially have to iterate through the entire Vector for each - // character of the base string, the Vector should be small (< 3 members). - void consumeBeforeAnyCharMatch(const Vector&); - - bool isConsumed() const { return m_index >= m_input.length(); } - -private: - String consumeQuotedString(); - void skipSpaces(); - - unsigned m_index = 0; - const String m_input; -}; - -} // namespace WebCore diff --git a/src/jsc/bindings/webcore/ResourceTiming.cpp b/src/jsc/bindings/webcore/ResourceTiming.cpp index f777f8a97ffd..84bf502b07e4 100644 --- a/src/jsc/bindings/webcore/ResourceTiming.cpp +++ b/src/jsc/bindings/webcore/ResourceTiming.cpp @@ -32,7 +32,6 @@ #include "PerformanceServerTiming.h" // #include "SecurityOrigin.h" #include "ResourceLoadTiming.h" -#include "ServerTimingParser.h" #include #include "NetworkLoadMetrics.h" diff --git a/src/jsc/bindings/webcore/ServerTiming.cpp b/src/jsc/bindings/webcore/ServerTiming.cpp index 05662c69346a..fb379dd5ccc9 100644 --- a/src/jsc/bindings/webcore/ServerTiming.cpp +++ b/src/jsc/bindings/webcore/ServerTiming.cpp @@ -28,24 +28,6 @@ namespace WebCore { -void ServerTiming::setParameter(const String& name, const String& value) -{ - if (equalLettersIgnoringASCIICase(name, "dur"_s)) { - if (!durationSet) { - duration = value.toDouble(); - durationSet = true; - } - return; - } - if (equalLettersIgnoringASCIICase(name, "desc"_s)) { - if (!descriptionSet) { - description = value; - descriptionSet = true; - } - return; - } -} - ServerTiming ServerTiming::isolatedCopy() const& { return ServerTiming { name.isolatedCopy(), duration, description.isolatedCopy(), durationSet, descriptionSet }; diff --git a/src/jsc/bindings/webcore/ServerTiming.h b/src/jsc/bindings/webcore/ServerTiming.h index 292a16202c1f..4e70165c0f5d 100644 --- a/src/jsc/bindings/webcore/ServerTiming.h +++ b/src/jsc/bindings/webcore/ServerTiming.h @@ -37,27 +37,12 @@ struct ServerTiming { bool durationSet = false; bool descriptionSet = false; - ServerTiming(String&& name); - ServerTiming(String&& name, double duration, String&& description); ServerTiming(String&& name, double duration, String&& description, bool durationSet, bool descriptionSet); - void setParameter(const String&, const String&); ServerTiming isolatedCopy() const&; ServerTiming isolatedCopy() &&; }; -inline ServerTiming::ServerTiming(String&& name) - : name(WTF::move(name)) -{ -} - -inline ServerTiming::ServerTiming(String&& name, double duration, String&& description) - : name(WTF::move(name)) - , duration(duration) - , description(WTF::move(description)) -{ -} - inline ServerTiming::ServerTiming(String&& name, double duration, String&& description, bool durationSet, bool descriptionSet) : name(WTF::move(name)) , duration(duration) diff --git a/src/jsc/bindings/webcore/ServerTimingParser.cpp b/src/jsc/bindings/webcore/ServerTimingParser.cpp deleted file mode 100644 index 1b2f79bf6b88..000000000000 --- a/src/jsc/bindings/webcore/ServerTimingParser.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2017 Akamai Technologies Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "ServerTimingParser.h" - -#include "HeaderFieldTokenizer.h" -#include "ServerTiming.h" - -#include - -namespace WebCore { - -namespace ServerTimingParser { - -Vector parseServerTiming(const String& headerValue) -{ - auto entries = Vector(); - if (headerValue.isNull()) - return entries; - - ASSERT(headerValue.is8Bit()); - - HeaderFieldTokenizer tokenizer(headerValue); - while (!tokenizer.isConsumed()) { - String name = tokenizer.consumeToken(); - if (name.isNull()) - break; - - ServerTiming entry(WTF::move(name)); - - while (tokenizer.consume(';')) { - String parameterName = tokenizer.consumeToken(); - if (parameterName.isNull()) - break; - - String value = emptyString(); - if (tokenizer.consume('=')) { - value = tokenizer.consumeTokenOrQuotedString(); - tokenizer.consumeBeforeAnyCharMatch({ ',', ';' }); - } - entry.setParameter(parameterName, value); - } - - entries.append(WTF::move(entry)); - - if (!tokenizer.consume(',')) - break; - } - return entries; -} - -} // namespace ServerTimingParser - -} // namespace WebCore diff --git a/src/jsc/bindings/webcore/ServerTimingParser.h b/src/jsc/bindings/webcore/ServerTimingParser.h deleted file mode 100644 index 5ee451dc7d9e..000000000000 --- a/src/jsc/bindings/webcore/ServerTimingParser.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2017 Akamai Technologies Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include - -namespace WebCore { - -struct ServerTiming; - -namespace ServerTimingParser { - -Vector parseServerTiming(const String&); - -} - -}