mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-23 21:27:44 +03:00
Fixed merge conflicts
This commit is contained in:
commit
ed5816d464
5 changed files with 48 additions and 11 deletions
18
CHANGELOG.md
18
CHANGELOG.md
|
@ -23,6 +23,24 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
|
|||
* *Nothing*
|
||||
|
||||
|
||||
## [3.1.2] - 2022-06-04
|
||||
### Added
|
||||
* *Nothing*
|
||||
|
||||
### Changed
|
||||
* *Nothing*
|
||||
|
||||
### Deprecated
|
||||
* *Nothing*
|
||||
|
||||
### Removed
|
||||
* *Nothing*
|
||||
|
||||
### Fixed
|
||||
* [#1448](https://github.com/shlinkio/shlink/issues/1448) Fixed HTML entities not being properly parsed when auto-resolving page titles.
|
||||
* [#1458](https://github.com/shlinkio/shlink/issues/1458) Fixed 500 error when filtering short URLs by ALL tags and search term.
|
||||
|
||||
|
||||
## [3.1.1] - 2022-05-09
|
||||
### Added
|
||||
* *Nothing*
|
||||
|
|
|
@ -102,15 +102,22 @@ class ShortUrlRepository extends EntitySpecificationRepository implements ShortU
|
|||
$qb->leftJoin('s.tags', 't');
|
||||
}
|
||||
|
||||
// Apply search conditions
|
||||
$qb->leftJoin('s.domain', 'd')
|
||||
->andWhere($qb->expr()->orX(
|
||||
// Apply general search conditions
|
||||
$conditions = [
|
||||
$qb->expr()->like('s.longUrl', ':searchPattern'),
|
||||
$qb->expr()->like('s.shortCode', ':searchPattern'),
|
||||
$qb->expr()->like('s.title', ':searchPattern'),
|
||||
$qb->expr()->like('t.name', ':searchPattern'),
|
||||
$qb->expr()->like('d.authority', ':searchPattern'),
|
||||
))
|
||||
];
|
||||
|
||||
// Apply tag conditions, only when not filtering by all provided tags
|
||||
$tagsMode = $filtering->tagsMode() ?? TagsMode::ANY;
|
||||
if (empty($tags) || $tagsMode === TagsMode::ANY) {
|
||||
$conditions[] = $qb->expr()->like('t.name', ':searchPattern');
|
||||
}
|
||||
|
||||
$qb->leftJoin('s.domain', 'd')
|
||||
->andWhere($qb->expr()->orX(...$conditions))
|
||||
->setParameter('searchPattern', '%' . $searchTerm . '%');
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ use Shlinkio\Shlink\Core\Exception\InvalidUrlException;
|
|||
use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
|
||||
use Throwable;
|
||||
|
||||
use function html_entity_decode;
|
||||
use function preg_match;
|
||||
use function str_contains;
|
||||
use function str_starts_with;
|
||||
|
@ -71,7 +72,7 @@ class UrlValidator implements UrlValidatorInterface, RequestMethodInterface
|
|||
$collectedBody .= $body->read(1024);
|
||||
}
|
||||
preg_match(TITLE_TAG_VALUE, $collectedBody, $matches);
|
||||
return isset($matches[1]) ? trim($matches[1]) : null;
|
||||
return isset($matches[1]) ? $this->normalizeTitle($matches[1]) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,4 +102,9 @@ class UrlValidator implements UrlValidatorInterface, RequestMethodInterface
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function normalizeTitle(string $title): string
|
||||
{
|
||||
return html_entity_decode(trim($title));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,6 +128,12 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
|
|||
self::assertEquals(1, $this->repo->countList(new ShortUrlsCountFiltering('foo', ['bar'])));
|
||||
self::assertSame($foo, $result[0]);
|
||||
|
||||
// Assert searched text also applies to tags
|
||||
$result = $this->repo->findList(new ShortUrlsListFiltering(null, null, Ordering::emptyInstance(), 'bar'));
|
||||
self::assertCount(2, $result);
|
||||
self::assertEquals(2, $this->repo->countList(new ShortUrlsCountFiltering('bar')));
|
||||
self::assertContains($foo, $result);
|
||||
|
||||
$result = $this->repo->findList(new ShortUrlsListFiltering(null, null, Ordering::emptyInstance()));
|
||||
self::assertCount(3, $result);
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ class UrlValidatorTest extends TestCase
|
|||
|
||||
$result = $this->urlValidator->validateUrlWithTitle('http://foobar.com/12345/hello?foo=bar', true);
|
||||
|
||||
self::assertEquals('Resolved title', $result);
|
||||
self::assertEquals('Resolved "title"', $result);
|
||||
$request->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ class UrlValidatorTest extends TestCase
|
|||
|
||||
private function respWithTitle(): Response
|
||||
{
|
||||
$body = $this->createStreamWithContent('<title data-foo="bar"> Resolved title</title>');
|
||||
$body = $this->createStreamWithContent('<title data-foo="bar"> Resolved "title" </title>');
|
||||
return new Response($body, 200, ['Content-Type' => 'TEXT/html; charset=utf-8']);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue