[bugzilla-gnome-org-extensions] Be robust against munged comments



commit 0c02ddab164c8ecd2b8a4758bfbb32dddc7f91b4
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Mon Sep 14 18:36:41 2009 -0400

    Be robust against munged comments
    
    Bugzilla 3.4 currently has bug where it line-wraps (and strips trailing
    whitespace) from comments in the XML output.
    
    Try to robust against this by ignoring lines we don't know about and
    treating '' the same as ' '. If the wrong thing gets wrapped, we can
    get confused and get a blank comment, but it's better than having
    the page stop loading entirely.

 js/review.js |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/js/review.js b/js/review.js
index 720d522..8ef8534 100644
--- a/js/review.js
+++ b/js/review.js
@@ -356,7 +356,10 @@ Review.prototype = {
                         count += parseInt(m3[1]);
                         i += 1;
                     }
-                    if (line.match(/^ /)) {
+                    console.log(line.length);
+                    // The check for /^$/ is because if Bugzilla is line-wrapping it also
+                    // strips completely whitespace lines
+                    if (line.match(/^ /) || line.match(/^$/)) {
                         oldLine += count;
                         newLine += count;
                         lastSegmentOld = 0;
@@ -370,7 +373,9 @@ Review.prototype = {
                     } else if (line.match(/^\\/)) {
                         // '\ No newline at end of file' - ignore
                     } else {
-                        throw "Bad content in hunk: " + line;
+                        // Ignore assumming it's a result of line-wrapping
+                        // https://bugzilla.mozilla.org/show_bug.cgi?id=509152
+                        console.log("WARNING: Bad content in hunk: " + line);
                     }
 
                     if ((oldStart == null || oldLine == oldStart + oldCount) &&
@@ -380,8 +385,10 @@ Review.prototype = {
                     }
                 }
 
-                if (commentText == null)
-                    throw "No comment found in hunk";
+                if (commentText == null) {
+                    console.log("WARNING: No comment found in hunk");
+                    commentText = "";
+                }
 
 
                 var location;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]