diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/platform/soup | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/platform/soup')
-rw-r--r-- | Source/WebCore/platform/soup/PublicSuffixSoup.cpp | 66 | ||||
-rw-r--r-- | Source/WebCore/platform/soup/SharedBufferSoup.cpp | 45 | ||||
-rw-r--r-- | Source/WebCore/platform/soup/URLSoup.cpp | 14 |
3 files changed, 114 insertions, 11 deletions
diff --git a/Source/WebCore/platform/soup/PublicSuffixSoup.cpp b/Source/WebCore/platform/soup/PublicSuffixSoup.cpp new file mode 100644 index 000000000..239c08194 --- /dev/null +++ b/Source/WebCore/platform/soup/PublicSuffixSoup.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2015 Igalia S.L. + * + * 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 APPLE INC. ``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 APPLE INC. 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 "PublicSuffix.h" + +#if ENABLE(PUBLIC_SUFFIX_LIST) + +#include <libsoup/soup.h> +#include <wtf/glib/GUniquePtr.h> + +namespace WebCore { + +bool isPublicSuffix(const String& domain) +{ + if (domain.isEmpty()) + return false; + + return soup_tld_domain_is_public_suffix(domain.utf8().data()); +} + +String topPrivatelyControlledDomain(const String& domain) +{ + if (domain.isEmpty()) + return String(); + + GUniqueOutPtr<GError> error; + CString domainUTF8 = domain.utf8(); + if (const char* baseDomain = soup_tld_get_base_domain(domainUTF8.data(), &error.outPtr())) + return String::fromUTF8(baseDomain); + + if (g_error_matches(error.get(), SOUP_TLD_ERROR, SOUP_TLD_ERROR_NO_BASE_DOMAIN) || g_error_matches(error.get(), SOUP_TLD_ERROR, SOUP_TLD_ERROR_NOT_ENOUGH_DOMAINS)) + return String(); + + if (g_error_matches(error.get(), SOUP_TLD_ERROR, SOUP_TLD_ERROR_IS_IP_ADDRESS) || g_error_matches(error.get(), SOUP_TLD_ERROR, SOUP_TLD_ERROR_INVALID_HOSTNAME)) + return domain; + + ASSERT_NOT_REACHED(); + return String(); +} + +} // namespace WebCore + +#endif // ENABLE(PUBLIC_SUFFIX_LIST) diff --git a/Source/WebCore/platform/soup/SharedBufferSoup.cpp b/Source/WebCore/platform/soup/SharedBufferSoup.cpp index 7457906cd..3b4b61a92 100644 --- a/Source/WebCore/platform/soup/SharedBufferSoup.cpp +++ b/Source/WebCore/platform/soup/SharedBufferSoup.cpp @@ -17,33 +17,44 @@ */ #include "config.h" + +#if USE(SOUP) + #include "SharedBuffer.h" -#include "PurgeableBuffer.h" #include <libsoup/soup.h> namespace WebCore { SharedBuffer::SharedBuffer(SoupBuffer* soupBuffer) - : m_size(0) + : m_buffer(*new DataBuffer) , m_soupBuffer(soupBuffer) { ASSERT(soupBuffer); } -PassRefPtr<SharedBuffer> SharedBuffer::wrapSoupBuffer(SoupBuffer* soupBuffer) +Ref<SharedBuffer> SharedBuffer::wrapSoupBuffer(SoupBuffer* soupBuffer) { - return adoptRef(new SharedBuffer(soupBuffer)); + return adoptRef(*new SharedBuffer(soupBuffer)); } -void SharedBuffer::clearPlatformData() +GUniquePtr<SoupBuffer> SharedBuffer::createSoupBuffer(unsigned offset, unsigned size) { - m_soupBuffer.reset(); + if (m_soupBuffer && !offset && !size) { + GUniquePtr<SoupBuffer> buffer(soup_buffer_copy(m_soupBuffer.get())); + return buffer; + } + + ref(); + GUniquePtr<SoupBuffer> buffer(soup_buffer_new_with_owner(data() + offset, size ? size : this->size(), this, [](void* data) { + static_cast<SharedBuffer*>(data)->deref(); + })); + return buffer; } -void SharedBuffer::tryReplaceContentsWithPlatformBuffer(SharedBuffer* newContents) +void SharedBuffer::clearPlatformData() { - ASSERT_NOT_REACHED(); + m_soupBuffer.reset(); } void SharedBuffer::maybeTransferPlatformData() @@ -76,4 +87,22 @@ unsigned SharedBuffer::platformDataSize() const return m_soupBuffer->length; } +bool SharedBuffer::maybeAppendPlatformData(SharedBuffer&) +{ + return false; +} + +bool SharedBuffer::tryReplaceContentsWithPlatformBuffer(SharedBuffer& newContents) +{ + if (!newContents.hasPlatformData()) + return false; + + clear(); + // FIXME: Use GRefPtr instead of GUniquePtr for the SoupBuffer. + m_soupBuffer.swap(newContents.m_soupBuffer); + return true; +} + } // namespace WebCore + +#endif diff --git a/Source/WebCore/platform/soup/URLSoup.cpp b/Source/WebCore/platform/soup/URLSoup.cpp index 70c7d27ff..f9f0d4b91 100644 --- a/Source/WebCore/platform/soup/URLSoup.cpp +++ b/Source/WebCore/platform/soup/URLSoup.cpp @@ -10,10 +10,10 @@ * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 @@ -24,8 +24,12 @@ */ #include "config.h" + +#if USE(SOUP) + #include "URL.h" +#include "URLParser.h" #include <libsoup/soup.h> #include <wtf/text/CString.h> @@ -39,7 +43,9 @@ URL::URL(SoupURI* soupURI) } GUniquePtr<gchar> urlString(soup_uri_to_string(soupURI, FALSE)); - parse(String::fromUTF8(urlString.get())); + URLParser parser(String::fromUTF8(urlString.get())); + *this = parser.result(); + if (!isValid()) return; @@ -61,3 +67,5 @@ GUniquePtr<SoupURI> URL::createSoupURI() const } } // namespace WebCore + +#endif |