Merge pull request #2063 from tpv-ebben/develop

when adding image to relationship first check that the generated RID is actually unique
This commit is contained in:
troosan 2021-05-29 17:58:25 +02:00 committed by GitHub
commit d905e764e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 4 deletions

View File

@ -1,4 +1,5 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
@ -748,7 +749,8 @@ class TemplateProcessor
// If tmpXmlRow doesn't contain continue, this row is no longer part of the spanned row.
$tmpXmlRow = $this->getSlice($extraRowStart, $extraRowEnd);
if (!preg_match('#<w:vMerge/>#', $tmpXmlRow) &&
!preg_match('#<w:vMerge w:val="continue"\s*/>#', $tmpXmlRow)) {
!preg_match('#<w:vMerge w:val="continue"\s*/>#', $tmpXmlRow)
) {
break;
}
// This row was a spanned row, update $rowEnd and search for the next row.
@ -1067,7 +1069,12 @@ class TemplateProcessor
protected function getNextRelationsIndex($documentPartName)
{
if (isset($this->tempDocumentRelations[$documentPartName])) {
return substr_count($this->tempDocumentRelations[$documentPartName], '<Relationship');
$candidate = substr_count($this->tempDocumentRelations[$documentPartName], '<Relationship');
while (strpos($this->tempDocumentRelations[$documentPartName], 'Id="rId' . $candidate . '"') !== false) {
$candidate++;
}
return $candidate;
}
return 1;