Skip to content

Commit 1715a7c

Browse files
author
Julien Veyssier
committed
move test, add comments for cleanup regexps
Signed-off-by: Julien Veyssier <[email protected]>
1 parent b95deb9 commit 1715a7c

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

lib/Service/ImageService.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ public static function getAttachmentNamesFromContent(string $content, int $fileI
485485
// simple version with .+ between the brackets
486486
// '/\!\[.+\]\(text:\/\/image\?[^)]*imageFileName=([^)&]+)\)/',
487487
// complex version of php-markdown
488+
// matches ![ANY_CONSIDERED_CORRECT_BY_PHP-MARKDOWN](text://image?ANYTHING&imageFileName=FILE_NAME) and captures FILE_NAME
488489
'/\!\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[\])*\])*\])*\])*\])*\])*\]\(text:\/\/image\?[^)]*imageFileName=([^)&]+)\)/',
489490
$content,
490491
$oldMatches,
@@ -495,6 +496,7 @@ public static function getAttachmentNamesFromContent(string $content, int $fileI
495496
}, $oldMatches);
496497

497498
$matches = [];
499+
// matches ![ANY_CONSIDERED_CORRECT_BY_PHP-MARKDOWN](.attachments.DOCUMENT_ID/ANY_FILE_NAME) and captures FILE_NAME
498500
preg_match_all(
499501
'/\!\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[\])*\])*\])*\])*\])*\])*\]\(\.attachments\.'.$fileId.'\/([^)&]+)\)/',
500502
$content,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use OCA\Text\Service\ImageService;
77
use OCP\Files\Folder;
88

9-
class TextTest extends \PHPUnit\Framework\TestCase {
9+
class ImageServiceTest extends \PHPUnit\Framework\TestCase {
1010
private static $attachmentNames = [
1111
'aaa.png',
1212
'aaa (2).png',

0 commit comments

Comments
 (0)