From 73b63a1f396396f5e86020ccbf6d56e9ee2d741e Mon Sep 17 00:00:00 2001 From: shibafu Date: Fri, 17 Jul 2020 21:46:25 +0900 Subject: [PATCH 01/15] update robots.txt --- public/robots.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/robots.txt b/public/robots.txt index eb05362..e2df9af 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,2 +1,3 @@ User-agent: * -Disallow: +Disallow: /api/ +Disallow: /search/ From 45645d9ae565797e8ea8b5eb6cfbfc777617e59c Mon Sep 17 00:00:00 2001 From: shibafu Date: Fri, 17 Jul 2020 22:23:37 +0900 Subject: [PATCH 02/15] =?UTF-8?q?=E8=B5=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/robots.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/public/robots.txt b/public/robots.txt index e2df9af..0f7399b 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,3 +1,2 @@ User-agent: * -Disallow: /api/ Disallow: /search/ From 16b5fb3533b5830e1a9fa49d52f666cb63270d43 Mon Sep 17 00:00:00 2001 From: shibafu Date: Tue, 21 Jul 2020 23:39:48 +0900 Subject: [PATCH 03/15] =?UTF-8?q?Tissue=E5=86=85=E3=81=AEURL=E3=81=AB?= =?UTF-8?q?=E5=AF=BE=E3=81=99=E3=82=8B=E3=83=A1=E3=82=BF=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E5=8F=96=E5=BE=97=E3=81=AF=E6=8B=92=E5=90=A6=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/MetadataResolveService.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Services/MetadataResolveService.php b/app/Services/MetadataResolveService.php index 405ae9f..55372bd 100644 --- a/app/Services/MetadataResolveService.php +++ b/app/Services/MetadataResolveService.php @@ -27,6 +27,11 @@ class MetadataResolveService // URLの正規化 $url = $this->formatter->normalizeUrl($url); + // 自分自身は解決しない + if (parse_url($url, PHP_URL_HOST) === parse_url(config('app.url'), PHP_URL_HOST)) { + abort(403); + } + // 無かったら取得 // TODO: ある程度古かったら再取得とかありだと思う $metadata = Metadata::find($url); From 0a9920b11cf1e0cfad654944e60a96a50478c5b7 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 23 Jul 2020 13:08:20 +0900 Subject: [PATCH 04/15] =?UTF-8?q?=E3=81=95=E3=81=99=E3=81=8C=E3=81=ABServi?= =?UTF-8?q?ce=E3=81=8B=E3=82=89HttpException=E3=81=AF=E9=9B=91=E3=81=99?= =?UTF-8?q?=E3=81=8E=E3=81=9F=E3=81=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/CardController.php | 7 ++++- app/Listeners/LinkCollector.php | 3 ++ app/MetadataResolver/DeniedHostException.php | 30 ++++++++++++++++++++ app/Services/MetadataResolveService.php | 3 +- 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 app/MetadataResolver/DeniedHostException.php diff --git a/app/Http/Controllers/Api/CardController.php b/app/Http/Controllers/Api/CardController.php index 8cdf980..38f56f7 100644 --- a/app/Http/Controllers/Api/CardController.php +++ b/app/Http/Controllers/Api/CardController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Api; +use App\MetadataResolver\DeniedHostException; use App\Services\MetadataResolveService; use Illuminate\Http\Request; @@ -13,7 +14,11 @@ class CardController 'url:required|url' ]); - $metadata = $service->execute($request->input('url')); + try { + $metadata = $service->execute($request->input('url')); + } catch (DeniedHostException $e) { + abort(403, $e->getMessage()); + } $metadata->load('tags'); $response = response($metadata); diff --git a/app/Listeners/LinkCollector.php b/app/Listeners/LinkCollector.php index 6c10e21..d3a1b37 100644 --- a/app/Listeners/LinkCollector.php +++ b/app/Listeners/LinkCollector.php @@ -3,6 +3,7 @@ namespace App\Listeners; use App\Events\LinkDiscovered; +use App\MetadataResolver\DeniedHostException; use App\Services\MetadataResolveService; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\InteractsWithQueue; @@ -32,6 +33,8 @@ class LinkCollector { try { $this->metadataResolveService->execute($event->url); + } catch (DeniedHostException $e) { + // ignored } catch (\Exception $e) { // 今のところこのイベントは同期実行されるので、上流をクラッシュさせないために雑catchする report($e); diff --git a/app/MetadataResolver/DeniedHostException.php b/app/MetadataResolver/DeniedHostException.php new file mode 100644 index 0000000..dac13b2 --- /dev/null +++ b/app/MetadataResolver/DeniedHostException.php @@ -0,0 +1,30 @@ +url = $url; + } + + public function getUrl(): string + { + return $this->url; + } + + public function getHost(): string + { + return parse_url($this->url, PHP_URL_HOST); + } +} diff --git a/app/Services/MetadataResolveService.php b/app/Services/MetadataResolveService.php index 55372bd..e622813 100644 --- a/app/Services/MetadataResolveService.php +++ b/app/Services/MetadataResolveService.php @@ -3,6 +3,7 @@ namespace App\Services; use App\Metadata; +use App\MetadataResolver\DeniedHostException; use App\MetadataResolver\MetadataResolver; use App\Tag; use App\Utilities\Formatter; @@ -29,7 +30,7 @@ class MetadataResolveService // 自分自身は解決しない if (parse_url($url, PHP_URL_HOST) === parse_url(config('app.url'), PHP_URL_HOST)) { - abort(403); + throw new DeniedHostException($url); } // 無かったら取得 From 978eccd643cd3fa628ce7347b7e375ecabcfe9e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D8=B1=D8=B2=D9=85=20=D8=A7=D9=84=D9=8A=D9=8E=D8=BA?= =?UTF-8?q?=D9=85=D9=8A=D8=B5=D8=A7=D8=A1?= <68658332+Al-aighumaisa@users.noreply.github.com> Date: Thu, 23 Jul 2020 02:42:42 +0900 Subject: [PATCH 05/15] =?UTF-8?q?=E3=82=BF=E3=82=B0=E3=81=AE=E7=A2=BA?= =?UTF-8?q?=E5=AE=9A=E6=99=82=E3=81=AB=E7=A9=BA=E7=99=BD=E6=96=87=E5=AD=97?= =?UTF-8?q?=E3=82=92=E7=BD=AE=E6=8F=9B=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #414. --- resources/assets/js/components/TagInput.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/assets/js/components/TagInput.vue b/resources/assets/js/components/TagInput.vue index 5dd2bad..9fad41f 100644 --- a/resources/assets/js/components/TagInput.vue +++ b/resources/assets/js/components/TagInput.vue @@ -41,7 +41,7 @@ export default class TagInput extends Vue { case 'Enter': case ' ': if ((event as any).isComposing !== true) { - this.tags.push(this.buffer.trim()); + this.tags.push(this.buffer.trim().replace(/\s+/g, '_')); this.buffer = ''; } event.preventDefault(); @@ -49,7 +49,7 @@ export default class TagInput extends Vue { case 'Unidentified': // 実際にテキストボックスに入力されている文字を見に行く (フォールバック処理) if (event.srcElement && (event.srcElement as HTMLInputElement).value.slice(-1) == ' ') { - this.tags.push(this.buffer.trim()); + this.tags.push(this.buffer.trim().replace(/\s+/g, '_')); this.buffer = ''; event.preventDefault(); } From d69fe6a22a23eb685c4e04db84bb03f2c57311a1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Jul 2020 12:41:43 +0900 Subject: [PATCH 06/15] Bump laravel/framework from 6.18.25 to 6.18.26 (#444) Bumps [laravel/framework](https://github.com/laravel/framework) from 6.18.25 to 6.18.26. - [Release notes](https://github.com/laravel/framework/releases) - [Changelog](https://github.com/laravel/framework/blob/7.x/CHANGELOG-6.x.md) - [Commits](https://github.com/laravel/framework/compare/v6.18.25...v6.18.26) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 516 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 369 insertions(+), 147 deletions(-) diff --git a/composer.lock b/composer.lock index f2192cf..5a68ddc 100644 --- a/composer.lock +++ b/composer.lock @@ -394,6 +394,20 @@ "sqlserver", "sqlsrv" ], + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal", + "type": "tidelift" + } + ], "time": "2020-04-20T17:19:26+00:00" }, { @@ -547,6 +561,20 @@ "uppercase", "words" ], + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector", + "type": "tidelift" + } + ], "time": "2020-05-29T15:13:26+00:00" }, { @@ -609,6 +637,20 @@ "parser", "php" ], + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer", + "type": "tidelift" + } + ], "time": "2020-05-25T17:44:05+00:00" }, { @@ -1148,16 +1190,16 @@ }, { "name": "laravel/framework", - "version": "v6.18.25", + "version": "v6.18.26", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "fd4c42cb49b8777473d1161ef15d1104b2a33d6c" + "reference": "d11b6168c65251ffa81ae0dfaf017ad2f30013da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/fd4c42cb49b8777473d1161ef15d1104b2a33d6c", - "reference": "fd4c42cb49b8777473d1161ef15d1104b2a33d6c", + "url": "https://api.github.com/repos/laravel/framework/zipball/d11b6168c65251ffa81ae0dfaf017ad2f30013da", + "reference": "d11b6168c65251ffa81ae0dfaf017ad2f30013da", "shasum": "" }, "require": { @@ -1292,7 +1334,7 @@ "framework", "laravel" ], - "time": "2020-07-10T16:41:03+00:00" + "time": "2020-07-21T14:25:39+00:00" }, { "name": "laravel/helpers", @@ -1413,16 +1455,16 @@ }, { "name": "league/commonmark", - "version": "1.5.1", + "version": "1.5.3", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "6d74caf6abeed5fd85d6ec20da23d7269cd0b46f" + "reference": "2574454b97e4103dc4e36917bd783b25624aefcd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/6d74caf6abeed5fd85d6ec20da23d7269cd0b46f", - "reference": "6d74caf6abeed5fd85d6ec20da23d7269cd0b46f", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/2574454b97e4103dc4e36917bd783b25624aefcd", + "reference": "2574454b97e4103dc4e36917bd783b25624aefcd", "shasum": "" }, "require": { @@ -1441,7 +1483,7 @@ "michelf/php-markdown": "~1.4", "mikehaertl/php-shellcommand": "^1.4", "phpstan/phpstan": "^0.12", - "phpunit/phpunit": "^7.5", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.2", "scrutinizer/ocular": "^1.5", "symfony/finder": "^4.2" }, @@ -1504,7 +1546,7 @@ "type": "tidelift" } ], - "time": "2020-06-27T12:50:08+00:00" + "time": "2020-07-19T22:47:30+00:00" }, { "name": "league/csv", @@ -1575,6 +1617,12 @@ "transform", "write" ], + "funding": [ + { + "url": "https://github.com/sponsors/nyamsprod", + "type": "github" + } + ], "time": "2020-03-17T15:15:35+00:00" }, { @@ -1659,6 +1707,12 @@ "sftp", "storage" ], + "funding": [ + { + "url": "https://offset.earth/frankdejonge", + "type": "other" + } + ], "time": "2020-05-18T15:13:39+00:00" }, { @@ -1785,6 +1839,16 @@ "logging", "psr-3" ], + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", + "type": "tidelift" + } + ], "time": "2020-05-22T08:12:19+00:00" }, { @@ -2509,24 +2573,24 @@ }, { "name": "phpoption/phpoption", - "version": "1.7.4", + "version": "1.7.5", "source": { "type": "git", "url": "https://github.com/schmittjoh/php-option.git", - "reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3" + "reference": "994ecccd8f3283ecf5ac33254543eb0ac946d525" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3", - "reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/994ecccd8f3283ecf5ac33254543eb0ac946d525", + "reference": "994ecccd8f3283ecf5ac33254543eb0ac946d525", "shasum": "" }, "require": { "php": "^5.5.9 || ^7.0 || ^8.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.3", - "phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0" + "bamarni/composer-bin-plugin": "^1.4.1", + "phpunit/phpunit": "^4.8.35 || ^5.7.27 || ^6.5.6 || ^7.0 || ^8.0 || ^9.0" }, "type": "library", "extra": { @@ -2570,7 +2634,7 @@ "type": "tidelift" } ], - "time": "2020-06-07T10:40:07+00:00" + "time": "2020-07-20T17:29:33+00:00" }, { "name": "psr/container", @@ -4359,16 +4423,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.17.1", + "version": "v1.18.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d" + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", - "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/1c302646f6efc070cd46856e600e5e0684d6b454", + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454", "shasum": "" }, "require": { @@ -4380,7 +4444,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-master": "1.18-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4431,20 +4495,20 @@ "type": "tidelift" } ], - "time": "2020-06-06T08:46:27+00:00" + "time": "2020-07-14T12:35:20+00:00" }, { "name": "symfony/polyfill-iconv", - "version": "v1.17.1", + "version": "v1.18.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-iconv.git", - "reference": "ba6c9c18db36235b859cc29b8372d1c01298c035" + "reference": "6c2f78eb8f5ab8eaea98f6d414a5915f2e0fce36" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/ba6c9c18db36235b859cc29b8372d1c01298c035", - "reference": "ba6c9c18db36235b859cc29b8372d1c01298c035", + "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/6c2f78eb8f5ab8eaea98f6d414a5915f2e0fce36", + "reference": "6c2f78eb8f5ab8eaea98f6d414a5915f2e0fce36", "shasum": "" }, "require": { @@ -4456,7 +4520,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-master": "1.18-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4508,25 +4572,26 @@ "type": "tidelift" } ], - "time": "2020-06-06T08:46:27+00:00" + "time": "2020-07-14T12:35:20+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.17.1", + "version": "v1.18.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "a57f8161502549a742a63c09f0a604997bf47027" + "reference": "bc6549d068d0160e0f10f7a5a23c7d1406b95ebe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/a57f8161502549a742a63c09f0a604997bf47027", - "reference": "a57f8161502549a742a63c09f0a604997bf47027", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/bc6549d068d0160e0f10f7a5a23c7d1406b95ebe", + "reference": "bc6549d068d0160e0f10f7a5a23c7d1406b95ebe", "shasum": "" }, "require": { "php": ">=5.3.3", - "symfony/polyfill-mbstring": "^1.3", + "symfony/polyfill-intl-normalizer": "^1.10", + "symfony/polyfill-php70": "^1.10", "symfony/polyfill-php72": "^1.10" }, "suggest": { @@ -4535,7 +4600,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-master": "1.18-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4559,6 +4624,10 @@ "name": "Laurent Bassin", "email": "laurent@bassin.info" }, + { + "name": "Trevor Rowbotham", + "email": "trevor.rowbotham@pm.me" + }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" @@ -4588,20 +4657,101 @@ "type": "tidelift" } ], - "time": "2020-06-06T08:46:27+00:00" + "time": "2020-07-14T12:35:20+00:00" }, { - "name": "symfony/polyfill-mbstring", - "version": "v1.17.1", + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.18.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "7110338d81ce1cbc3e273136e4574663627037a7" + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "37078a8dd4a2a1e9ab0231af7c6cb671b2ed5a7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7110338d81ce1cbc3e273136e4574663627037a7", - "reference": "7110338d81ce1cbc3e273136e4574663627037a7", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/37078a8dd4a2a1e9ab0231af7c6cb671b2ed5a7e", + "reference": "37078a8dd4a2a1e9ab0231af7c6cb671b2ed5a7e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.18.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/a6977d63bf9a0ad4c65cd352709e230876f9904a", + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a", "shasum": "" }, "require": { @@ -4613,7 +4763,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-master": "1.18-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4665,20 +4815,97 @@ "type": "tidelift" } ], + "time": "2020-07-14T12:35:20+00:00" + }, + { + "name": "symfony/polyfill-php70", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php70.git", + "reference": "471b096aede7025bace8eb356b9ac801aaba7e2d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/471b096aede7025bace8eb356b9ac801aaba7e2d", + "reference": "471b096aede7025bace8eb356b9ac801aaba7e2d", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "~1.0|~2.0|~9.99", + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php70\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-06-06T08:46:27+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.17.0", + "version": "v1.18.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "f048e612a3905f34931127360bdd2def19a5e582" + "reference": "639447d008615574653fb3bc60d1986d7172eaae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/f048e612a3905f34931127360bdd2def19a5e582", - "reference": "f048e612a3905f34931127360bdd2def19a5e582", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/639447d008615574653fb3bc60d1986d7172eaae", + "reference": "639447d008615574653fb3bc60d1986d7172eaae", "shasum": "" }, "require": { @@ -4687,7 +4914,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -4720,20 +4951,34 @@ "portable", "shim" ], - "time": "2020-05-12T16:47:27+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.17.1", + "version": "v1.18.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "fa0837fe02d617d31fbb25f990655861bb27bd1a" + "reference": "fffa1a52a023e782cdcc221d781fe1ec8f87fcca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fa0837fe02d617d31fbb25f990655861bb27bd1a", - "reference": "fa0837fe02d617d31fbb25f990655861bb27bd1a", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fffa1a52a023e782cdcc221d781fe1ec8f87fcca", + "reference": "fffa1a52a023e782cdcc221d781fe1ec8f87fcca", "shasum": "" }, "require": { @@ -4742,7 +4987,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-master": "1.18-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4796,20 +5041,20 @@ "type": "tidelift" } ], - "time": "2020-06-06T08:46:27+00:00" + "time": "2020-07-14T12:35:20+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.17.1", + "version": "v1.18.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2" + "reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4a5b6bba3259902e386eb80dd1956181ee90b5b2", - "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/d87d5766cbf48d72388a9f6b85f280c8ad51f981", + "reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981", "shasum": "" }, "require": { @@ -4818,7 +5063,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-master": "1.18-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4876,7 +5121,7 @@ "type": "tidelift" } ], - "time": "2020-06-06T08:46:27+00:00" + "time": "2020-07-14T12:35:20+00:00" }, { "name": "symfony/polyfill-uuid", @@ -5491,22 +5736,22 @@ }, { "name": "vlucas/phpdotenv", - "version": "v3.6.6", + "version": "v3.6.7", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "4669484ccbc38fe7c4e0c50456778f2010566aad" + "reference": "2065beda6cbe75e2603686907b2e45f6f3a5ad82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/4669484ccbc38fe7c4e0c50456778f2010566aad", - "reference": "4669484ccbc38fe7c4e0c50456778f2010566aad", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/2065beda6cbe75e2603686907b2e45f6f3a5ad82", + "reference": "2065beda6cbe75e2603686907b2e45f6f3a5ad82", "shasum": "" }, "require": { "php": "^5.4 || ^7.0 || ^8.0", "phpoption/phpoption": "^1.5.2", - "symfony/polyfill-ctype": "^1.16" + "symfony/polyfill-ctype": "^1.17" }, "require-dev": { "ext-filter": "*", @@ -5560,7 +5805,7 @@ "type": "tidelift" } ], - "time": "2020-06-02T14:08:54+00:00" + "time": "2020-07-14T19:04:52+00:00" } ], "packages-dev": [ @@ -5630,6 +5875,12 @@ "profiler", "webprofiler" ], + "funding": [ + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], "time": "2020-05-05T10:53:32+00:00" }, { @@ -5701,6 +5952,12 @@ "phpstorm", "sublime" ], + "funding": [ + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], "time": "2020-04-22T09:57:26+00:00" }, { @@ -5806,6 +6063,16 @@ "ssl", "tls" ], + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], "time": "2020-04-08T08:27:21+00:00" }, { @@ -5887,6 +6154,16 @@ "dependency", "package" ], + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], "time": "2020-05-06T08:28:10+00:00" }, { @@ -6259,6 +6536,12 @@ "flare", "reporting" ], + "funding": [ + { + "url": "https://www.patreon.com/spatie", + "type": "patreon" + } + ], "time": "2020-03-02T15:52:04+00:00" }, { @@ -7805,6 +8088,12 @@ "highlight.php", "syntax" ], + "funding": [ + { + "url": "https://github.com/allejo", + "type": "github" + } + ], "time": "2020-03-02T05:59:21+00:00" }, { @@ -8469,6 +8758,16 @@ "parser", "validator" ], + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/seld/jsonlint", + "type": "tidelift" + } + ], "time": "2020-04-30T19:05:18+00:00" }, { @@ -8579,83 +8878,6 @@ ], "time": "2020-05-30T20:35:19+00:00" }, - { - "name": "symfony/polyfill-php70", - "version": "v1.17.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "471b096aede7025bace8eb356b9ac801aaba7e2d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/471b096aede7025bace8eb356b9ac801aaba7e2d", - "reference": "471b096aede7025bace8eb356b9ac801aaba7e2d", - "shasum": "" - }, - "require": { - "paragonie/random_compat": "~1.0|~2.0|~9.99", - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.17-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php70\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-06-06T08:46:27+00:00" - }, { "name": "symfony/stopwatch", "version": "v5.1.2", @@ -8810,8 +9032,8 @@ "authors": [ { "name": "Arne Blankerts", - "role": "Developer", - "email": "arne@blankerts.de" + "email": "arne@blankerts.de", + "role": "Developer" } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", From c7aa0026251c884ce6ad5ab92e7889aeec827cb6 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 30 Jul 2020 00:46:33 +0900 Subject: [PATCH 07/15] =?UTF-8?q?=E3=81=AA=E3=82=93=E3=82=82=E3=82=8F?= =?UTF-8?q?=E3=81=8B=E3=82=89=E3=82=93=E3=82=8F=E3=83=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/NormalizeTags.php | 50 ++++++++++++++++++++++++++ app/Utilities/Formatter.php | 11 ++++++ 2 files changed, 61 insertions(+) create mode 100644 app/Console/Commands/NormalizeTags.php diff --git a/app/Console/Commands/NormalizeTags.php b/app/Console/Commands/NormalizeTags.php new file mode 100644 index 0000000..4e9d8ed --- /dev/null +++ b/app/Console/Commands/NormalizeTags.php @@ -0,0 +1,50 @@ +formatter = $formatter; + } + + /** + * Execute the console command. + * + * @return mixed + */ + public function handle() + { + foreach (Tag::query()->orderBy('name')->cursor() as $tag) { + $normalizedName = $this->formatter->normalizeToSearchIndex($tag->name); + $this->line("{$tag->name} : {$normalizedName}"); + } + } +} diff --git a/app/Utilities/Formatter.php b/app/Utilities/Formatter.php index 7ac108b..aa09c78 100644 --- a/app/Utilities/Formatter.php +++ b/app/Utilities/Formatter.php @@ -132,4 +132,15 @@ class Formatter return $bytes . 'B'; } + + public function normalizeToSearchIndex(string $text): string + { + $text = \Normalizer::normalize($text, \Normalizer::FORM_KC); +// $text = \Transliterator::create('Katakana-Hiragana')->transliterate($text); + $text = mb_convert_kana($text, 'c'); + $text = preg_replace('/[^\p{L}\p{N}]/u', '', $text); + $text = mb_strtolower($text); + + return $text; + } } From e2c43fef802dbdc7ab046bf5c5cc6fd61eb5d634 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 30 Jul 2020 22:42:10 +0900 Subject: [PATCH 08/15] tags.normalized_name --- app/Console/Commands/NormalizeTags.php | 19 ++++++++--- app/Tag.php | 10 ++++++ app/Utilities/Formatter.php | 11 +++---- ..._30_221302_add_normalized_name_to_tags.php | 32 +++++++++++++++++++ 4 files changed, 61 insertions(+), 11 deletions(-) create mode 100644 database/migrations/2020_07_30_221302_add_normalized_name_to_tags.php diff --git a/app/Console/Commands/NormalizeTags.php b/app/Console/Commands/NormalizeTags.php index 4e9d8ed..9d6cf30 100644 --- a/app/Console/Commands/NormalizeTags.php +++ b/app/Console/Commands/NormalizeTags.php @@ -4,6 +4,7 @@ namespace App\Console\Commands; use App\Tag; use App\Utilities\Formatter; +use DB; use Illuminate\Console\Command; class NormalizeTags extends Command @@ -42,9 +43,19 @@ class NormalizeTags extends Command */ public function handle() { - foreach (Tag::query()->orderBy('name')->cursor() as $tag) { - $normalizedName = $this->formatter->normalizeToSearchIndex($tag->name); - $this->line("{$tag->name} : {$normalizedName}"); - } + $start = hrtime(true); + + DB::transaction(function () { + /** @var Tag $tag */ + foreach (Tag::query()->cursor() as $tag) { + $normalizedName = $this->formatter->normalizeTagName($tag->name); + $this->line("{$tag->name} : {$normalizedName}"); + $tag->normalized_name = $normalizedName; + $tag->save(); + } + }); + + $elapsed = (hrtime(true) - $start) / 1e+9; + $this->info("Done! ({$elapsed} sec)"); } } diff --git a/app/Tag.php b/app/Tag.php index df057f5..895492e 100644 --- a/app/Tag.php +++ b/app/Tag.php @@ -2,6 +2,7 @@ namespace App; +use App\Utilities\Formatter; use Illuminate\Database\Eloquent\Model; class Tag extends Model @@ -15,6 +16,15 @@ class Tag extends Model 'name' ]; + protected static function boot() + { + parent::boot(); + + self::creating(function (Tag $tag) { + $tag->normalized_name = app(Formatter::class)->normalizeTagName($tag->name); + }); + } + public function ejaculations() { return $this->belongsToMany('App\Ejaculation')->withTimestamps(); diff --git a/app/Utilities/Formatter.php b/app/Utilities/Formatter.php index aa09c78..f15901a 100644 --- a/app/Utilities/Formatter.php +++ b/app/Utilities/Formatter.php @@ -133,14 +133,11 @@ class Formatter return $bytes . 'B'; } - public function normalizeToSearchIndex(string $text): string + public function normalizeTagName(string $name) { - $text = \Normalizer::normalize($text, \Normalizer::FORM_KC); -// $text = \Transliterator::create('Katakana-Hiragana')->transliterate($text); - $text = mb_convert_kana($text, 'c'); - $text = preg_replace('/[^\p{L}\p{N}]/u', '', $text); - $text = mb_strtolower($text); + $name = \Normalizer::normalize($name, \Normalizer::FORM_KC); + $name = mb_strtolower($name); - return $text; + return $name; } } diff --git a/database/migrations/2020_07_30_221302_add_normalized_name_to_tags.php b/database/migrations/2020_07_30_221302_add_normalized_name_to_tags.php new file mode 100644 index 0000000..eead2a0 --- /dev/null +++ b/database/migrations/2020_07_30_221302_add_normalized_name_to_tags.php @@ -0,0 +1,32 @@ +string('normalized_name')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('tags', function (Blueprint $table) { + $table->dropColumn('normalized_name'); + }); + } +} From d18f245129116b84fef34e36964de4de0cfde11d Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 30 Jul 2020 23:04:39 +0900 Subject: [PATCH 09/15] Docker: use php-intl --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index fd99670..d8530ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,8 @@ FROM php:7.3-apache ENV APACHE_DOCUMENT_ROOT /var/www/html/public RUN apt-get update \ - && apt-get install -y git libpq-dev unzip \ - && docker-php-ext-install pdo_pgsql \ + && apt-get install -y git libpq-dev unzip libicu-dev \ + && docker-php-ext-install pdo_pgsql intl \ && pecl install xdebug \ && curl -sS https://getcomposer.org/installer | php \ && mv composer.phar /usr/local/bin/composer \ From 561c9d028da59549356e1a70f54e2d4388fa8f43 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 30 Jul 2020 23:12:29 +0900 Subject: [PATCH 10/15] =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E6=99=82=E3=81=AB?= =?UTF-8?q?=E3=81=AFtags.normalized=5Fname=E3=82=92=E4=BD=BF=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/SearchController.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 0487344..ee4b5c0 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -4,20 +4,30 @@ namespace App\Http\Controllers; use App\Ejaculation; use App\Tag; +use App\Utilities\Formatter; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; class SearchController extends Controller { + /** @var Formatter */ + private $formatter; + + public function __construct(Formatter $formatter) + { + $this->formatter = $formatter; + } + public function index(Request $request) { $inputs = $request->validate([ 'q' => 'required' ]); + $q = $this->normalizeQuery($inputs['q']); $results = Ejaculation::query() - ->whereHas('tags', function ($query) use ($inputs) { - $query->where('name', 'like', "%{$inputs['q']}%"); + ->whereHas('tags', function ($query) use ($q) { + $query->where('normalized_name', 'like', "%{$q}%"); }) ->whereHas('user', function ($query) { $query->where('is_protected', false); @@ -41,11 +51,17 @@ class SearchController extends Controller 'q' => 'required' ]); + $q = $this->normalizeQuery($inputs['q']); $results = Tag::query() - ->where('name', 'like', "%{$inputs['q']}%") + ->where('normalized_name', 'like', "%{$q}%") ->paginate(50) ->appends($inputs); return view('search.relatedTag')->with(compact('inputs', 'results')); } + + private function normalizeQuery(string $query): string + { + return $this->formatter->normalizeTagName($query); + } } From c9efcb538cae0b2a68f60c3b4df36efc86c1e210 Mon Sep 17 00:00:00 2001 From: shibafu Date: Fri, 31 Jul 2020 22:21:31 +0900 Subject: [PATCH 11/15] add extension requirements --- composer.json | 6 +++ composer.lock | 104 +++++--------------------------------------------- 2 files changed, 16 insertions(+), 94 deletions(-) diff --git a/composer.json b/composer.json index c262a1c..f5a796c 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,12 @@ ], "require": { "php": "^7.2", + "ext-dom": "*", + "ext-intl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-pdo": "*", "anhskohbo/no-captcha": "^3.0", "doctrine/dbal": "^2.9", "erusev/parsedown": "^1.7", diff --git a/composer.lock b/composer.lock index 5a68ddc..a0f42c5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2c0bd951a595d4856079c5a13a72e651", + "content-hash": "1bba68b609be6a0dcdaf05d72e8eb759", "packages": [ { "name": "anhskohbo/no-captcha", @@ -394,20 +394,6 @@ "sqlserver", "sqlsrv" ], - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal", - "type": "tidelift" - } - ], "time": "2020-04-20T17:19:26+00:00" }, { @@ -1617,12 +1603,6 @@ "transform", "write" ], - "funding": [ - { - "url": "https://github.com/sponsors/nyamsprod", - "type": "github" - } - ], "time": "2020-03-17T15:15:35+00:00" }, { @@ -1707,12 +1687,6 @@ "sftp", "storage" ], - "funding": [ - { - "url": "https://offset.earth/frankdejonge", - "type": "other" - } - ], "time": "2020-05-18T15:13:39+00:00" }, { @@ -1839,16 +1813,6 @@ "logging", "psr-3" ], - "funding": [ - { - "url": "https://github.com/Seldaek", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", - "type": "tidelift" - } - ], "time": "2020-05-22T08:12:19+00:00" }, { @@ -5875,12 +5839,6 @@ "profiler", "webprofiler" ], - "funding": [ - { - "url": "https://github.com/barryvdh", - "type": "github" - } - ], "time": "2020-05-05T10:53:32+00:00" }, { @@ -5952,12 +5910,6 @@ "phpstorm", "sublime" ], - "funding": [ - { - "url": "https://github.com/barryvdh", - "type": "github" - } - ], "time": "2020-04-22T09:57:26+00:00" }, { @@ -6063,16 +6015,6 @@ "ssl", "tls" ], - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], "time": "2020-04-08T08:27:21+00:00" }, { @@ -6154,16 +6096,6 @@ "dependency", "package" ], - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], "time": "2020-05-06T08:28:10+00:00" }, { @@ -6536,12 +6468,6 @@ "flare", "reporting" ], - "funding": [ - { - "url": "https://www.patreon.com/spatie", - "type": "patreon" - } - ], "time": "2020-03-02T15:52:04+00:00" }, { @@ -8088,12 +8014,6 @@ "highlight.php", "syntax" ], - "funding": [ - { - "url": "https://github.com/allejo", - "type": "github" - } - ], "time": "2020-03-02T05:59:21+00:00" }, { @@ -8758,16 +8678,6 @@ "parser", "validator" ], - "funding": [ - { - "url": "https://github.com/Seldaek", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/seld/jsonlint", - "type": "tidelift" - } - ], "time": "2020-04-30T19:05:18+00:00" }, { @@ -9032,8 +8942,8 @@ "authors": [ { "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" + "role": "Developer", + "email": "arne@blankerts.de" } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", @@ -9097,7 +9007,13 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": "^7.2" + "php": "^7.2", + "ext-dom": "*", + "ext-intl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-pdo": "*" }, "platform-dev": [], "plugin-api-version": "1.1.0" From b5901f26bfce09d86d8dd89b288cb655fd67f768 Mon Sep 17 00:00:00 2001 From: shibafu Date: Fri, 31 Jul 2020 23:10:54 +0900 Subject: [PATCH 12/15] add test --- tests/Unit/Utilities/FormatterTest.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/Unit/Utilities/FormatterTest.php b/tests/Unit/Utilities/FormatterTest.php index 843e60f..1708e4b 100644 --- a/tests/Unit/Utilities/FormatterTest.php +++ b/tests/Unit/Utilities/FormatterTest.php @@ -70,4 +70,30 @@ class FormatterTest extends TestCase $formatter->profileImageSrcSet($profileImageProvider, 128, 2) ); } + + /** + * @dataProvider provideNormalizeTagName + */ + public function testNormalizeTagName($input, $expected) + { + $formatter = new Formatter(); + + $normalized = $formatter->normalizeTagName($input); + $this->assertSame($expected, $normalized); + $this->assertSame($expected, $formatter->normalizeTagName($normalized)); + } + + public function provideNormalizeTagName() + { + return [ + 'LowerCase' => ['example', 'example'], + 'UpperCase' => ['EXAMPLE', 'example'], + 'HalfWidthKana' => ['ティッシュ', 'ティッシュ'], + 'FullWidthAlphabet' => ['Tissue', 'tissue'], + '組み文字1' => ['13㎝', '13cm'], + '組み文字2' => ['13㌢㍍', '13センチメートル'], + 'Script' => ['ℬ𝒶𝒷𝓊𝓂𝒾', 'babumi'], + '分割された濁点' => ['オカス゛', 'オカズ'], + ]; + } } From 18ae64a8704c826a58401fbe34e281e5ccb55cc6 Mon Sep 17 00:00:00 2001 From: shibafu Date: Fri, 31 Jul 2020 23:19:35 +0900 Subject: [PATCH 13/15] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=81=84=E3=81=AE=E3=81=AFNFD=E3=81=A0=E3=81=A3?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Unit/Utilities/FormatterTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/Utilities/FormatterTest.php b/tests/Unit/Utilities/FormatterTest.php index 1708e4b..46718fa 100644 --- a/tests/Unit/Utilities/FormatterTest.php +++ b/tests/Unit/Utilities/FormatterTest.php @@ -93,7 +93,7 @@ class FormatterTest extends TestCase '組み文字1' => ['13㎝', '13cm'], '組み文字2' => ['13㌢㍍', '13センチメートル'], 'Script' => ['ℬ𝒶𝒷𝓊𝓂𝒾', 'babumi'], - '分割された濁点' => ['オカス゛', 'オカズ'], + 'NFD' => ['オカズ', 'オカズ'], ]; } } From f8a93fdf454d7b970aad296f143f52ef48b008de Mon Sep 17 00:00:00 2001 From: shibafu Date: Sat, 1 Aug 2020 17:26:38 +0900 Subject: [PATCH 14/15] =?UTF-8?q?Metadata=E8=A7=A3=E6=B1=BA=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E3=83=88=E3=83=A9=E3=83=B3=E3=82=B6=E3=82=AF?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E5=86=85=E3=81=A7=E5=AE=9F=E8=A1=8C?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/MetadataResolveService.php | 49 +++++++++++++------------ 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/app/Services/MetadataResolveService.php b/app/Services/MetadataResolveService.php index e622813..48a4246 100644 --- a/app/Services/MetadataResolveService.php +++ b/app/Services/MetadataResolveService.php @@ -8,6 +8,7 @@ use App\MetadataResolver\MetadataResolver; use App\Tag; use App\Utilities\Formatter; use GuzzleHttp\Exception\TransferException; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; class MetadataResolveService @@ -33,32 +34,34 @@ class MetadataResolveService throw new DeniedHostException($url); } - // 無かったら取得 - // TODO: ある程度古かったら再取得とかありだと思う - $metadata = Metadata::find($url); - if ($metadata == null || ($metadata->expires_at !== null && $metadata->expires_at < now())) { - try { - $resolved = $this->resolver->resolve($url); - $metadata = Metadata::updateOrCreate(['url' => $url], [ - 'title' => $resolved->title, - 'description' => $resolved->description, - 'image' => $resolved->image, - 'expires_at' => $resolved->expires_at - ]); + return DB::transaction(function () use ($url) { + // 無かったら取得 + // TODO: ある程度古かったら再取得とかありだと思う + $metadata = Metadata::find($url); + if ($metadata == null || ($metadata->expires_at !== null && $metadata->expires_at < now())) { + try { + $resolved = $this->resolver->resolve($url); + $metadata = Metadata::updateOrCreate(['url' => $url], [ + 'title' => $resolved->title, + 'description' => $resolved->description, + 'image' => $resolved->image, + 'expires_at' => $resolved->expires_at + ]); - $tagIds = []; - foreach ($resolved->normalizedTags() as $tagName) { - $tag = Tag::firstOrCreate(['name' => $tagName]); - $tagIds[] = $tag->id; + $tagIds = []; + foreach ($resolved->normalizedTags() as $tagName) { + $tag = Tag::firstOrCreate(['name' => $tagName]); + $tagIds[] = $tag->id; + } + $metadata->tags()->sync($tagIds); + } catch (TransferException $e) { + // 何らかの通信エラーによってメタデータの取得に失敗した時、とりあえずエラーログにURLを残す + Log::error(self::class . ': メタデータの取得に失敗 URL=' . $url); + throw $e; } - $metadata->tags()->sync($tagIds); - } catch (TransferException $e) { - // 何らかの通信エラーによってメタデータの取得に失敗した時、とりあえずエラーログにURLを残す - Log::error(self::class . ': メタデータの取得に失敗 URL=' . $url); - throw $e; } - } - return $metadata; + return $metadata; + }); } } From 54e112fa577315718893c803d16223f9a9a66a01 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Aug 2020 10:11:59 +0000 Subject: [PATCH 15/15] Bump elliptic from 6.5.2 to 6.5.3 (#449) --- yarn.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index d181104..96ceb48 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1496,9 +1496,9 @@ bluebird@^3.1.1, bluebird@^3.5.5: integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0: - version "4.11.8" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" - integrity sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA== + version "4.11.9" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828" + integrity sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw== body-parser@1.19.0: version "1.19.0" @@ -2865,9 +2865,9 @@ elegant-spinner@^1.0.1: integrity sha1-2wQ1IcldfjA/2PNFvtwzSc+wcp4= elliptic@^6.0.0: - version "6.5.2" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.2.tgz#05c5678d7173c049d8ca433552224a495d0e3762" - integrity sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw== + version "6.5.3" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.3.tgz#cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6" + integrity sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw== dependencies: bn.js "^4.4.0" brorand "^1.0.1"