Title: [168579] trunk/Source/WebCore
Revision
168579
Author
[email protected]
Date
2014-05-10 12:48:50 -0700 (Sat, 10 May 2014)

Log Message

Block exceptions when trying to convert attributed strings to RTF and RTFD
https://bugs.webkit.org/show_bug.cgi?id=132778
<rdar://problem/16675805>

Reviewed by Darin Adler.

When the iOS WebHTMLConverter was upstreamed, converting some attributed strings to RTF and RTFD
started throwing Objective-C exceptions (see <rdar://problem/16876920>).

In WebKit2, we now crash on unhandled exceptions so work around that crash by adding exception blocking macros.

* editing/ios/EditorIOS.mm:
(WebCore::dataInRTFDFormat):
(WebCore::dataInRTFFormat):
* editing/mac/EditorMac.mm:
(WebCore::dataInRTFDFormat):
(WebCore::dataInRTFFormat):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (168578 => 168579)


--- trunk/Source/WebCore/ChangeLog	2014-05-10 19:14:21 UTC (rev 168578)
+++ trunk/Source/WebCore/ChangeLog	2014-05-10 19:48:50 UTC (rev 168579)
@@ -1,3 +1,23 @@
+2014-05-10  Anders Carlsson  <[email protected]>
+
+        Block exceptions when trying to convert attributed strings to RTF and RTFD
+        https://bugs.webkit.org/show_bug.cgi?id=132778
+        <rdar://problem/16675805>
+
+        Reviewed by Darin Adler.
+
+        When the iOS WebHTMLConverter was upstreamed, converting some attributed strings to RTF and RTFD
+        started throwing Objective-C exceptions (see <rdar://problem/16876920>).
+        
+        In WebKit2, we now crash on unhandled exceptions so work around that crash by adding exception blocking macros.
+
+        * editing/ios/EditorIOS.mm:
+        (WebCore::dataInRTFDFormat):
+        (WebCore::dataInRTFFormat):
+        * editing/mac/EditorMac.mm:
+        (WebCore::dataInRTFDFormat):
+        (WebCore::dataInRTFFormat):
+
 2014-05-10  Zan Dobersek  <[email protected]>
 
         Move Source/WebCore/workers/ code to std::unique_ptr

Modified: trunk/Source/WebCore/editing/ios/EditorIOS.mm (168578 => 168579)


--- trunk/Source/WebCore/editing/ios/EditorIOS.mm	2014-05-10 19:14:21 UTC (rev 168578)
+++ trunk/Source/WebCore/editing/ios/EditorIOS.mm	2014-05-10 19:48:50 UTC (rev 168579)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "Editor.h"
 
+#include "BlockExceptions.h"
 #include "CachedImage.h"
 #include "CSSComputedStyleDeclaration.h"
 #include "CSSPrimitiveValueMappings.h"
@@ -299,16 +300,30 @@
 
 static PassRefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *string)
 {
-    NSUInteger length = [string length];
-    return length ? SharedBuffer::wrapNSData([string RTFDFromRange:NSMakeRange(0, length) documentAttributes:nil]) : nullptr;
+    NSUInteger length = string.length;
+    if (!length)
+        return nullptr;
+
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    return SharedBuffer::wrapNSData([string RTFDFromRange:NSMakeRange(0, length) documentAttributes:nil]);
+    END_BLOCK_OBJC_EXCEPTIONS;
+
+    return nullptr;
 }
 
 static PassRefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *string)
 {
-    NSUInteger length = [string length];
-    return length ? SharedBuffer::wrapNSData([string RTFFromRange:NSMakeRange(0, length) documentAttributes:nil]) : nullptr;
-}    
+    NSUInteger length = string.length;
+    if (!length)
+        return nullptr;
 
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    return SharedBuffer::wrapNSData([string RTFFromRange:NSMakeRange(0, length) documentAttributes:nil]);
+    END_BLOCK_OBJC_EXCEPTIONS;
+
+    return nullptr;
+}
+
 String Editor::stringSelectionForPasteboardWithImageAltText()
 {
     String text = selectedTextForDataTransfer();

Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (168578 => 168579)


--- trunk/Source/WebCore/editing/mac/EditorMac.mm	2014-05-10 19:14:21 UTC (rev 168578)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm	2014-05-10 19:48:50 UTC (rev 168579)
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "Editor.h"
 
+#import "BlockExceptions.h"
 #import "CachedResourceLoader.h"
 #import "ColorMac.h"
 #import "DOMRangeInternal.h"
@@ -319,14 +320,28 @@
     
 static PassRefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *string)
 {
-    NSUInteger length = [string length];
-    return length ? SharedBuffer::wrapNSData([string RTFDFromRange:NSMakeRange(0, length) documentAttributes:nil]) : 0;
+    NSUInteger length = string.length;
+    if (!length)
+        return nullptr;
+
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    return SharedBuffer::wrapNSData([string RTFDFromRange:NSMakeRange(0, length) documentAttributes:nil]);
+    END_BLOCK_OBJC_EXCEPTIONS;
+
+    return nullptr;
 }
 
 static PassRefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *string)
 {
-    NSUInteger length = [string length];
-    return length ? SharedBuffer::wrapNSData([string RTFFromRange:NSMakeRange(0, length) documentAttributes:nil]) : 0;
+    NSUInteger length = string.length;
+    if (!length)
+        return nullptr;
+
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    return SharedBuffer::wrapNSData([string RTFFromRange:NSMakeRange(0, length) documentAttributes:nil]);
+    END_BLOCK_OBJC_EXCEPTIONS;
+
+    return nullptr;
 }
 
 PassRefPtr<SharedBuffer> Editor::dataSelectionForPasteboard(const String& pasteboardType)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to