Allow replying to New: bugs too.
authorShawn Wilsher <me@shawnwilsher.com>
Fri, 20 Nov 2009 17:17:10 -0800
changeset 35 352894da53a13995160d03e5216f202a6822c48d
parent 34 b4ea70b85de947ee9c090d6f65b2ad9871687178
child 36 8b728f2e281f0d74486ae935ccc63f94fc3f8e8a
push id19
push usersdwilsh@shawnwilsher.com
push dateSat, 21 Nov 2009 02:37:49 +0000
Allow replying to New: bugs too.
content/overlay.js
--- a/content/overlay.js
+++ b/content/overlay.js
@@ -74,37 +74,49 @@ var BugzillaReply = {
                                        32768,
                                        false,
                                        true,
                                        { });
   },
 
   getComment: function BR_getComment(aMessageBody)
   {
-    let message = aMessageBody.replace("\r\n", "\n");
+    let message = aMessageBody;
+    while (message.indexOf("\r") != -1)
+      message = message.replace("\r", "");
 
     let lines = message.split("\n");
     let foundURI = false;
     let foundHeader = false;
     let foundEnd = false;
-    let bug, commentNumber;
+    let bug, commentNumber = 0, emptyLines = 0;
     let commentLines = lines.filter(function(line) {
       // If we have already found the end, we don't want this line.
       if (foundEnd)
         return false;
 
       if (!foundURI) {
         let match = BugzillaReply.kBugURIRegEx.exec(line);
         if (!match)
           return false;
         bug = match[1];
         foundURI = true;
         return false;
       }
 
+      // Two empty lines is the header for a new bug, so track them and check.
+      if (line.length)
+        emptyLines = 0;
+      else
+        emptyLines++;
+      if (emptyLines == 2) {
+        foundHeader = true;
+        return false;
+      }
+
       // If we haven't found the header yet, check for it.
       if (!foundHeader) {
         let match = BugzillaReply.kCommentStartRegEx.exec(line);
         if (!match)
           return false;
         commentNumber = match[1];
         foundHeader = true;
         return false;