From 35587831f1919d78d2c46f0422be4d00f7c7fe9f Mon Sep 17 00:00:00 2001 From: Kent James Date: Sat, 1 Sep 2012 15:36:15 -0700 Subject: [PATCH] Bug 780908 - Fix crash in editor when head after body. r=ehsan, a=Standard8 for checkin to Thunderbird specific relbranch CLOSED TREE --HG-- branch : COMM1501_2012090708_RELBRANCH extra : transplant_source : %C8%92Rq5%CDl%ED%5B%E7%5E%FB%3E%E1G%40W%F6m%91 --- editor/libeditor/html/nsHTMLEditor.cpp | 9 ++ editor/libeditor/html/tests/Makefile.in | 1 + .../libeditor/html/tests/test_bug780908.xul | 113 ++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 editor/libeditor/html/tests/test_bug780908.xul diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index b477f506f29b..502aa2ed6e0d 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -1500,6 +1500,9 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString) aSourceString.EndReading(endhead); bool foundhead = CaseInsensitiveFindInReadable(NS_LITERAL_STRING(" beginbody.get()) + foundhead = false; nsReadingIterator beginclosehead; nsReadingIterator endclosehead; @@ -1509,6 +1512,12 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString) // Find the index after "" bool foundclosehead = CaseInsensitiveFindInReadable( NS_LITERAL_STRING(""), beginclosehead, endclosehead); + // a valid close head appears after a found head + if (foundhead && beginhead.get() > beginclosehead.get()) + foundclosehead = false; + // a valid close head appears before a found body + if (foundbody && beginclosehead.get() > beginbody.get()) + foundclosehead = false; // Time to change the document nsAutoEditBatch beginBatching(this); diff --git a/editor/libeditor/html/tests/Makefile.in b/editor/libeditor/html/tests/Makefile.in index de9b9502a0ac..df617612ea9c 100644 --- a/editor/libeditor/html/tests/Makefile.in +++ b/editor/libeditor/html/tests/Makefile.in @@ -103,6 +103,7 @@ _CHROME_TEST_FILES = \ test_bug607584.xul \ test_bug616590.xul \ test_bug635636.html \ + test_bug780908.xul \ green.png \ $(NULL) diff --git a/editor/libeditor/html/tests/test_bug780908.xul b/editor/libeditor/html/tests/test_bug780908.xul new file mode 100644 index 000000000000..95b65de11154 --- /dev/null +++ b/editor/libeditor/html/tests/test_bug780908.xul @@ -0,0 +1,113 @@ + + + + + + +