Changeset 206744 in webkit
- Timestamp:
- Oct 3, 2016 1:27:33 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r206736 r206744 1 2016-10-03 Andy Estes <aestes@apple.com> 2 3 ASSERTION FAILED: url.containsOnlyASCII() in WebCore::checkEncodedString() when parsing an invalid CSS cursor URL 4 https://bugs.webkit.org/show_bug.cgi?id=162763 5 <rdar://problem/28572758> 6 7 Reviewed by Youenn Fablet. 8 9 * fast/css/cursor-with-invalid-url.html: Added. 10 * fast/css/cursor-with-invalid-url-expected.txt: Added. 11 1 12 2016-10-03 Andy Estes <aestes@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r206743 r206744 1 2016-10-03 Andy Estes <aestes@apple.com> 2 3 ASSERTION FAILED: url.containsOnlyASCII() in WebCore::checkEncodedString() when parsing an invalid CSS cursor URL 4 https://bugs.webkit.org/show_bug.cgi?id=162763 5 <rdar://problem/28572758> 6 7 Reviewed by Youenn Fablet. 8 9 CSSCursorImageValue copies the URL of its underlying CSSImageValue by using the 10 ParsedURLString URL constructor on the String returned by CSSImageValue::url(). While 11 CSSImageValues were always being constructed from a URL implicitly converted to a String, 12 nothing ensured that the URL was valid. For invalid URLs, URL::string() returns the string 13 it was constructed with, which might still represent a relative URL or contain non-ASCII 14 characters, violating the preconditions of the ParsedURLString URL constructor and causing 15 an assertion to fail in Debug builds. 16 17 Fix this by having CSSImageValue store its image URL using a WebCore::URL rather than a 18 String. CSSCursorImageValue can then copy this URL instead of attempting to re-parse a 19 possibly-invalid URL string. 20 21 Test: fast/css/cursor-with-invalid-url.html 22 23 * css/CSSCursorImageValue.cpp: 24 (WebCore::CSSCursorImageValue::CSSCursorImageValue): Copied m_imageValue.url() into 25 m_originalURL instead of using the ParsedURLString URL constructor, since 26 CSSImageValue::url() now returns a WebCore::URL. 27 (WebCore::CSSCursorImageValue::loadImage): Created a URL from cursorElement->href() by 28 calling Document::completeURL(). 29 * css/CSSImageValue.cpp: 30 (WebCore::CSSImageValue::CSSImageValue): Changed to take a URL&& instead of a const String&. 31 (WebCore::CSSImageValue::loadImage): Stopped calling Document::completeURL(), since m_url is 32 now a WebCore::URL. 33 * css/CSSImageValue.h: Changed url() to return a const URL&, and changed m_url to be a URL. 34 * html/HTMLBodyElement.cpp: 35 (WebCore::HTMLBodyElement::collectStyleForPresentationAttribute): Removed a call to 36 URL::string(). 37 * html/HTMLTableElement.cpp: 38 (WebCore::HTMLTableElement::collectStyleForPresentationAttribute): Ditto. 39 * html/HTMLTablePartElement.cpp: 40 (WebCore::HTMLTablePartElement::collectStyleForPresentationAttribute): Ditto. 41 1 42 2016-10-03 Zalan Bujtas <zalan@apple.com> 2 43 -
trunk/Source/WebCore/css/CSSCursorImageValue.cpp
r205419 r206744 45 45 { 46 46 if (is<CSSImageValue>(m_imageValue.get())) 47 m_originalURL = { ParsedURLString, downcast<CSSImageValue>(m_imageValue.get()).url() };47 m_originalURL = downcast<CSSImageValue>(m_imageValue.get()).url(); 48 48 } 49 49 … … 108 108 if (auto* cursorElement = updateCursorElement(*loader.document())) { 109 109 if (cursorElement->href() != downcast<CSSImageValue>(m_imageValue.get()).url()) 110 m_imageValue = CSSImageValue::create( cursorElement->href());110 m_imageValue = CSSImageValue::create(loader.document()->completeURL(cursorElement->href())); 111 111 } 112 112 -
trunk/Source/WebCore/css/CSSImageValue.cpp
r206016 r206744 36 36 namespace WebCore { 37 37 38 CSSImageValue::CSSImageValue( const String& url)38 CSSImageValue::CSSImageValue(URL&& url) 39 39 : CSSValue(ImageClass) 40 , m_url( url)40 , m_url(WTFMove(url)) 41 41 , m_accessedImage(false) 42 42 { … … 66 66 m_accessedImage = true; 67 67 68 CachedResourceRequest request(ResourceRequest( loader.document()->completeURL(m_url)), options);68 CachedResourceRequest request(ResourceRequest(m_url), options); 69 69 if (m_initiatorName.isEmpty()) 70 70 request.setInitiator(cachedResourceRequestInitiators().css); -
trunk/Source/WebCore/css/CSSImageValue.h
r205419 r206744 19 19 */ 20 20 21 #ifndef CSSImageValue_h 22 #define CSSImageValue_h 21 #pragma once 23 22 24 23 #include "CSSValue.h" 25 24 #include "CachedResourceHandle.h" 26 #include <wtf/Ref Ptr.h>25 #include <wtf/Ref.h> 27 26 28 27 namespace WebCore { … … 30 29 class CachedImage; 31 30 class CachedResourceLoader; 32 class Element;33 31 class RenderElement; 34 32 struct ResourceLoaderOptions; … … 36 34 class CSSImageValue final : public CSSValue { 37 35 public: 38 static Ref<CSSImageValue> create( const String& url) { return adoptRef(*new CSSImageValue(url)); }36 static Ref<CSSImageValue> create(URL&& url) { return adoptRef(*new CSSImageValue(WTFMove(url))); } 39 37 static Ref<CSSImageValue> create(CachedImage& image) { return adoptRef(*new CSSImageValue(image)); } 40 38 ~CSSImageValue(); … … 44 42 CachedImage* cachedImage() const { return m_cachedImage.get(); } 45 43 46 const String& url() const { return m_url; }44 const URL& url() const { return m_url; } 47 45 48 46 String customCSSText() const; … … 59 57 60 58 private: 61 explicit CSSImageValue( const String& url);59 explicit CSSImageValue(URL&&); 62 60 explicit CSSImageValue(CachedImage&); 63 61 64 Stringm_url;62 URL m_url; 65 63 CachedResourceHandle<CachedImage> m_cachedImage; 66 64 bool m_accessedImage; … … 71 69 72 70 SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSImageValue, isImageValue()) 73 74 #endif // CSSImageValue_h -
trunk/Source/WebCore/html/HTMLBodyElement.cpp
r205897 r206744 83 83 String url = stripLeadingAndTrailingHTMLSpaces(value); 84 84 if (!url.isEmpty()) { 85 auto imageValue = CSSImageValue::create(document().completeURL(url) .string());85 auto imageValue = CSSImageValue::create(document().completeURL(url)); 86 86 imageValue.get().setInitiator(localName()); 87 87 style.setProperty(CSSProperty(CSSPropertyBackgroundImage, WTFMove(imageValue))); -
trunk/Source/WebCore/html/HTMLTableElement.cpp
r203324 r206744 333 333 String url = stripLeadingAndTrailingHTMLSpaces(value); 334 334 if (!url.isEmpty()) 335 style.setProperty(CSSProperty(CSSPropertyBackgroundImage, CSSImageValue::create(document().completeURL(url) .string())));335 style.setProperty(CSSProperty(CSSPropertyBackgroundImage, CSSImageValue::create(document().completeURL(url)))); 336 336 } else if (name == valignAttr) { 337 337 if (!value.isEmpty()) -
trunk/Source/WebCore/html/HTMLTablePartElement.cpp
r195452 r206744 53 53 String url = stripLeadingAndTrailingHTMLSpaces(value); 54 54 if (!url.isEmpty()) 55 style.setProperty(CSSProperty(CSSPropertyBackgroundImage, CSSImageValue::create(document().completeURL(url) .string())));55 style.setProperty(CSSProperty(CSSPropertyBackgroundImage, CSSImageValue::create(document().completeURL(url)))); 56 56 } else if (name == valignAttr) { 57 57 if (equalLettersIgnoringASCIICase(value, "top"))
Note: See TracChangeset
for help on using the changeset viewer.