Skip to content

Commit 7e9853d

Browse files
committed
Check for empty oldText or newText before processing del or ins in processReplaceOperation
1 parent 082c6d0 commit 7e9853d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/Caxy/HtmlDiff/HtmlDiff.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,20 @@ private function performOperation($operation)
353353

354354
private function processReplaceOperation($operation)
355355
{
356-
$this->processDeleteOperation( $operation, "diffmod" );
357-
if ($this->insertSpaceInReplace) {
356+
$processDelete = strlen($this->oldText) > 0;
357+
$processInsert = strlen($this->newText) > 0;
358+
359+
if ($processDelete) {
360+
$this->processDeleteOperation( $operation, "diffmod" );
361+
}
362+
363+
if ($this->insertSpaceInReplace && $processDelete && $processInsert) {
358364
$this->content .= ' ';
359365
}
360-
$this->processInsertOperation( $operation, "diffmod" );
366+
367+
if ($processInsert) {
368+
$this->processInsertOperation( $operation, "diffmod" );
369+
}
361370
}
362371

363372
private function processInsertOperation($operation, $cssClass)

0 commit comments

Comments
 (0)