Skip to content

Commit

Permalink
Escape the delimiter (#48765)
Browse files Browse the repository at this point in the history
Co-authored-by: Stan Daniëls <[email protected]>
  • Loading branch information
standaniels and standaniels authored Oct 18, 2023
1 parent ada0a01 commit 19c0454
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public static function excerpt($text, $phrase = '', $options = [])
$radius = $options['radius'] ?? 100;
$omission = $options['omission'] ?? '...';

preg_match('/^(.*?)('.preg_quote((string) $phrase).')(.*)$/iu', (string) $text, $matches);
preg_match('/^(.*?)('.preg_quote((string) $phrase, '/').')(.*)$/iu', (string) $text, $matches);

if (empty($matches)) {
return null;
Expand Down
1 change: 1 addition & 0 deletions tests/Support/SupportStrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public function testStrExcerpt()
$this->assertSame('...ocê e...', Str::excerpt('Como você está', 'Ê', ['radius' => 2]));
$this->assertSame('João...', Str::excerpt('João Antônio ', 'jo', ['radius' => 2]));
$this->assertSame('João Antô...', Str::excerpt('João Antônio', 'JOÃO', ['radius' => 5]));
$this->assertNull(Str::excerpt('', '/'));
}

public function testStrBefore()
Expand Down

0 comments on commit 19c0454

Please sign in to comment.