Commit af6f9d8
authored
patch: improve validation of ed diffs
* Make more of an effort to reject patches where line addresses are not valid
* Reading over the ed command parser in Patch::Ed::apply(), the regex assignment was not always correct
* test1: "19,0d" command was incorrectly interpreted as "19,19d" thanks to the '||' operator
* test2: "19,18d" command was accepted, but the range is backwards
* test3: "0,19d" command was accepted, but address 0 is not allowed for "d"
* test4: "0,19c" command was accepted, but address 0 is not allowed for "c"
* I tested this by skipping to PLAN_J, using a modified diff with an update on line1 (ed command 0a is valid and means append after line 0)
* Modifying elements of the diff input, I could trigger the new validation errors
%perl diff -e env env2 | perl tee env.diff
19,20d
5,8c
META DATA
AND MORE
.
0a
#NEW LINE 1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.1 parent f2d8543 commit af6f9d8
1 file changed
+8
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
988 | 988 | | |
989 | 989 | | |
990 | 990 | | |
991 | | - | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
992 | 999 | | |
993 | 1000 | | |
994 | 1001 | | |
| |||
0 commit comments