Bug 8928 - REPRODUCIBLE ASSERT: Cannot paste HTML into a contenteditable region in an XHTML document
Summary: REPRODUCIBLE ASSERT: Cannot paste HTML into a contenteditable region in an XH...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P1 Normal
Assignee: Darin Adler
URL:
Keywords: HasReduction, InRadar
Depends on:
Blocks:
 
Reported: 2006-05-15 15:45 PDT by Levi Weintraub
Modified: 2007-03-09 11:08 PST (History)
4 users (show)

See Also:


Attachments
Test Case (301 bytes, application/xhtml+xml)
2006-05-15 15:50 PDT, Levi Weintraub
no flags Details
patch (18.54 KB, patch)
2007-03-09 08:22 PST, Darin Adler
justin.garcia: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Levi Weintraub 2006-05-15 15:45:39 PDT
I can copy portions of an XHTML document and paste them into a contenteditable div on an HTML document, but nothing happens when I try to paste into an equivalent div in an XHTML document. Pasting plaintext works fine.

Will attach test case.
Comment 1 Levi Weintraub 2006-05-15 15:50:35 PDT
Created attachment 8332 [details]
Test Case

Steps to reproduce:
1. Highlight the text that says "Copy this" and copy it.
2. Click inside the contenteditable region below next to where it says "Paste it here."
3. Attempt to paste.

Alternatively, you can highlight the "Copy this" text and attempt to drag it into the contenteditable region.
Comment 2 Dan POPA 2007-03-05 01:19:50 PST
(In reply to comment #1)
> Created an attachment (id=8332) [edit]
> Test Case
> 
> Steps to reproduce:
> 1. Highlight the text that says "Copy this" and copy it.
> 2. Click inside the contenteditable region below next to where it says "Paste
> it here."
> 3. Attempt to paste.
> 
> Alternatively, you can highlight the "Copy this" text and attempt to drag it
> into the contenteditable region.
> 
I still can reproduce this in WebKit-SVN-r19955.dmg using the attached testcase.
Comment 3 David Kilzer (:ddkilzer) 2007-03-05 03:58:38 PST
On a local debug build of WebKit r19953, the steps in Comment #1 lead to an assertion failure.  Console output:

ASSERTION FAILED: fragment
(/path/to/WebKit/WebCore/editing/markup.cpp:586 WTF::PassRefPtr<WebCore::DocumentFragment> WebCore::createFragmentFromMarkup(WebCore::Document*, const WebCore::String&, const WebCore::String&))
Segmentation fault

Stack trace:

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:      KERN_INVALID_ADDRESS (0x0001) at 0xbbadbeef

Thread 0 Crashed:
0   com.apple.WebCore        	0x01249e00 WebCore::createFragmentFromMarkup(WebCore::Document*, WebCore::String const&, WebCore::String const&) + 288 (markup.cpp:586)
1   com.apple.WebCore        	0x01115478 -[WebCoreFrameBridge documentFragmentWithMarkupString:baseURLString:] + 232 (WebCoreFrameBridge.mm:1058)
2   com.apple.WebKit         	0x0033bc2c -[WebDataSource(WebInternal) _documentFragmentWithArchive:] + 532 (WebDataSource.mm:245)
3   com.apple.WebKit         	0x00366958 -[WebHTMLView(WebPrivate) _documentFragmentFromPasteboard:forType:inContext:subresources:] + 328 (WebHTMLView.mm:1814)
4   com.apple.WebKit         	0x00344330 -[WebHTMLView(WebHTMLViewFileInternal) _documentFragmentFromPasteboard:inContext:allowPlainText:chosePlainText:] + 220 (WebHTMLView.mm:450)
5   com.apple.WebKit         	0x00344e70 -[WebHTMLView(WebHTMLViewFileInternal) _pasteWithPasteboard:allowPlainText:] + 136 (WebHTMLView.mm:560)
6   com.apple.WebKit         	0x00359b24 -[WebHTMLView(WebInternal) paste:] + 360 (WebHTMLView.mm:5104)
7   com.apple.AppKit         	0x937adc4c -[NSApplication sendAction:to:from:] + 108
8   com.apple.Safari         	0x0002956c 0x1000 + 165228
9   com.apple.AppKit         	0x938084b8 -[NSMenu performActionForItemAtIndex:] + 392
10  com.apple.AppKit         	0x9380823c -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 104
11  com.apple.AppKit         	0x93807ce4 -[NSMenu performKeyEquivalent:] + 272
12  com.apple.AppKit         	0x93807930 -[NSApplication _handleKeyEquivalent:] + 328
13  com.apple.AppKit         	0x93711408 -[NSApplication sendEvent:] + 2944
14  com.apple.Safari         	0x00021238 0x1000 + 131640
15  com.apple.AppKit         	0x93708d10 -[NSApplication run] + 508
16  com.apple.AppKit         	0x937f987c NSApplicationMain + 452
17  com.apple.Safari         	0x0005c77c 0x1000 + 374652
18  com.apple.Safari         	0x0005c624 0x1000 + 374308

Comment 4 Mark Rowe (bdash) 2007-03-07 06:44:30 PST
<rdar://problem/5045708>
Comment 5 Darin Adler 2007-03-09 08:22:51 PST
Created attachment 13559 [details]
patch

This is enough to get plain text pasting working and to eliminate the assertion and crash.

Rich text pasting still won't work, but that should presumably be covered by another bug.
Comment 6 Justin Garcia 2007-03-09 11:00:13 PST
Comment on attachment 13559 [details]
patch

r=me
Comment 7 Darin Adler 2007-03-09 11:08:59 PST
Committed revision 20092.