diff options
author | Andreas Gohr <andi@splitbrain.org> | 2011-10-10 20:25:47 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2011-10-10 20:25:47 +0200 |
commit | b824abd4a1f0a1458e89c5f023902687ee1730e9 (patch) | |
tree | 6b677c394870cf45302dc086cdca18b25fd9e85a /inc/changelog.php | |
parent | 8032624921fc54dae6c6f44f55b8209738876113 (diff) | |
download | rpg-b824abd4a1f0a1458e89c5f023902687ee1730e9.tar.gz rpg-b824abd4a1f0a1458e89c5f023902687ee1730e9.tar.bz2 |
Fixes a problem with parsing overlong changelog lines
When an overlong edit summary was given for an edit, the resulting
changelog line could be longer than the chunk that is handled in the
changelog reader (8192 bytes) causing the reader to abort the operation.
This meant that old revisions where no longer accessible. This patch
fixes the reader (it continues reading chunks until a full line is
found).
However, limiting the summary makes sense and will be added in another
patch.
Diffstat (limited to 'inc/changelog.php')
-rw-r--r-- | inc/changelog.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/inc/changelog.php b/inc/changelog.php index fea39f9f7..3162df01a 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -454,8 +454,9 @@ function getRevisions($id, $first, $num, $chunk_size=8192, $media=false) { } $num = max($num, 0); $chunk_size = max($chunk_size, 0); - if ($first<0) { $first = 0; } - else if (!$media && @file_exists(wikiFN($id)) || $media && @file_exists(mediaFN($id))) { + if ($first<0) { + $first = 0; + } else if (!$media && @file_exists(wikiFN($id)) || $media && @file_exists(mediaFN($id))) { // skip current revision if the page exists $first = max($first+1, 0); } @@ -476,13 +477,21 @@ function getRevisions($id, $first, $num, $chunk_size=8192, $media=false) { $finger = max($tail-$chunk_size, 0); while ($count<$num+$first) { fseek($fp, $finger); + $nl = $finger; if ($finger>0) { fgets($fp); // slip the finger forward to a new line - $finger = ftell($fp); + $nl = ftell($fp); + } + + // was the chunk big enough? if not, take another bite + if($nl > 0 && $tail <= $nl){ + $finger = max($finger-$chunk_size, 0); + continue; + }else{ + $finger = $nl; } // read chunk - if ($tail<=$finger) { break; } $chunk = ''; $read_size = max($tail-$finger, 0); // found chunk size $got = 0; |