Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 1553 by hortonlkh: patch crash in reviewboard, post-review's difflib_unified_diff() fails to handle missing newline terminated file
http://code.google.com/p/reviewboard/issues/detail?id=1553

*NOTE: Do not post confidential information in this bug report.*

What version are you running?
1.0.5.1

What's the URL of the page containing the problem?
1. http://reviewboard2.efi.com/r/[request id]/
2. click "View Diff"

What steps will reproduce the problem?
1. post-review a file whose previous version does not have newline
terminated, and the working copy extends from the previous version from a
clearcase repos
2. http://reviewboard2.efi.com/r/[request id]/
3. click "View Diff"

What is the expected output? What do you see instead?
crash; last function in backtrace is patch()

What operating system are you using? What browser?
post-review from linux, firefox reviewboard from windows

Please provide any additional information below.
The problem is from python's difflib.unified_diff() that fails to
output "\\ No newline at end of file" in the diff file.

According to post-review source code, post-review tries to remedy this, but
it fails in the case when the copy version extends from the version that is
missing newline.

e.g.
### note missing \n after close curly brace
old_file_content = """
int Foo(const char* path)
{
    int ret = -1;

    return ret;
}"""

new_file_content = """
int Foo(const char* path)
{
    int ret = -1;

    return ret;
}

int Bar(void)
{
    int return = 0;
    return ret;
}
"""

diff -u output:
# diff -u oldold.cpp newnew.cpp

--- oldold.cpp  2010-03-17 15:08:36.600738000 -0700
+++ newnew.cpp  2010-03-17 15:06:19.641658000 -0700
@@ -3,4 +3,10 @@
     int ret = -1;

     return ret;
-}
\ No newline at end of file
+}
+
+int Bar(void)
+{
+    int return = 0;
+    return ret;
+}


post-review (difflib_unified_diff). I slightly modify post-review to get
this output.
Note: "-}+}"

--- /vobs/.../src/oldold.cpp   2002-02-21 23:30:39.942229878 -0800
+++ /vobs/.../src/newnew.cpp   2002-02-21 23:30:50.442260588 -0800
@@ -3,4 +3,10 @@
     int ret = -1;

     return ret;
-}+}
+
+int Bar(void)
+{
+    int return = 0;
+    return ret;
+}


Unix patch command on reviewboard does not like "-}+}" and crash.

I installed python2.6 recently and difflib still have this bug!

My suggested workaround:
In post-review, add '\n' to the original file if is not
newline terminated. In reviewboard diffutils.py, possibly
convert_line_endings(data),
add '\n' to data if data[-1] is not '\r' or '\n'

Thank you.
(newline terminated)


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"reviewboard-issues" group.
To post to this group, send email to reviewboard-iss...@googlegroups.com.
To unsubscribe from this group, send email to 
reviewboard-issues+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/reviewboard-issues?hl=en.

Reply via email to