Skip to content

Commit

Permalink
fix(AttachmentService): make regex in getAttachmentIdsFromContent mor…
Browse files Browse the repository at this point in the history
…e permissive

Signed-off-by: Peter Birrer <peter.birrer@optonic.com>
  • Loading branch information
pbirrer committed Feb 10, 2025
1 parent cda0403 commit dfe7677
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Service/AttachmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,9 @@ function ($node) use ($contentAttachmentFileIds, $contentAttachmentNames) {
*/
public static function getAttachmentIdsFromContent(string $content): array {
$matches = [];
// matches [ANY_CONSIDERED_CORRECT_BY_PHP-MARKDOWN](ANY_URL/f/FILE_ID[ (preview)]) and captures FILE_ID
// matches [ANY_CONSIDERED_CORRECT_BY_PHP-MARKDOWN](ANY_URL/f/FILE_ID and captures FILE_ID
preg_match_all(
'/\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[\])*\])*\])*\])*\])*\])*\]\(\S+\/f\/(\d+)(?: \(preview\))?\)/',
'/\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[(?>[^\[\]]+|\[\])*\])*\])*\])*\])*\])*\]\(\S+\/f\/(\d+)/',
$content,
$matches,
PREG_SET_ORDER
Expand Down

0 comments on commit dfe7677

Please sign in to comment.