mirror of
https://github.com/Kovah/LinkAce.git
synced 2025-02-24 11:13:02 +01:00
commit
8d22b733c5
@ -126,8 +126,13 @@ class HtmlMeta
|
||||
?? self::$fallback['description'];
|
||||
|
||||
if (isset($metaTags['charset']) && strtolower($metaTags['charset']) !== 'utf-8') {
|
||||
$title = iconv($metaTags['charset'], 'UTF-8', $title) ?: null;
|
||||
$description = iconv($metaTags['charset'], 'UTF-8', $description) ?: null;
|
||||
try {
|
||||
$title = iconv($metaTags['charset'], 'UTF-8', $title) ?: null;
|
||||
$description = iconv($metaTags['charset'], 'UTF-8', $description) ?: null;
|
||||
} catch (\ErrorException $e) {
|
||||
$title = null;
|
||||
$description = null;
|
||||
}
|
||||
} elseif (mb_detect_encoding($title, 'UTF-8', true) === false) {
|
||||
$title = null;
|
||||
$description = null;
|
||||
|
@ -29,9 +29,10 @@ class SearchRequest extends FormRequest
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'query' => 'bail|required_without_all:only_lists,only_tags',
|
||||
'only_lists' => 'bail|required_without_all:query,only_tags',
|
||||
'only_tags' => 'bail|required_without_all:query,only_lists',
|
||||
'query' => 'bail|required_without_all:only_lists,only_tags,broken_only',
|
||||
'only_lists' => 'bail|required_without_all:query,only_tags,broken_only',
|
||||
'only_tags' => 'bail|required_without_all:query,only_lists,broken_only',
|
||||
'broken_only' => 'bail|required_without_all:query,only_lists,only_tags',
|
||||
];
|
||||
}
|
||||
|
||||
@ -44,8 +45,9 @@ class SearchRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'query.required_without_all' => trans('search.validation_query_missing'),
|
||||
'only_lists.required_without_all' => trans('search.validation_lists_missing'),
|
||||
'only_tags.required_without_all' => trans('search.validation_tags_missing'),
|
||||
'only_lists.required_without_all' => trans('search.validation_query_missing'),
|
||||
'only_tags.required_without_all' => trans('search.validation_query_missing'),
|
||||
'broken_only.required_without_all' => trans('search.validation_query_missing'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
659
composer.lock
generated
659
composer.lock
generated
File diff suppressed because it is too large
Load Diff
62
config/cors.php
Normal file
62
config/cors.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel CORS Options
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The allowed_methods and allowed_headers options are case-insensitive.
|
||||
|
|
||||
| You don't need to provide both allowed_origins and allowed_origins_patterns.
|
||||
| If one of the strings passed matches, it is considered a valid origin.
|
||||
|
|
||||
| If ['*'] is provided to allowed_methods, allowed_origins or allowed_headers
|
||||
| all methods / origins / headers are allowed.
|
||||
|
|
||||
*/
|
||||
|
||||
/*
|
||||
* You can enable CORS for 1 or multiple paths.
|
||||
* Example: ['api/*']
|
||||
*/
|
||||
'paths' => [
|
||||
'api/*'
|
||||
],
|
||||
|
||||
/*
|
||||
* Matches the request method. `['*']` allows all methods.
|
||||
*/
|
||||
'allowed_methods' => ['*'],
|
||||
|
||||
/*
|
||||
* Matches the request origin. `['*']` allows all origins. Wildcards can be used, eg `*.mydomain.com`
|
||||
*/
|
||||
'allowed_origins' => ['*'],
|
||||
|
||||
/*
|
||||
* Patterns that can be used with `preg_match` to match the origin.
|
||||
*/
|
||||
'allowed_origins_patterns' => [],
|
||||
|
||||
/*
|
||||
* Sets the Access-Control-Allow-Headers response header. `['*']` allows all headers.
|
||||
*/
|
||||
'allowed_headers' => ['*'],
|
||||
|
||||
/*
|
||||
* Sets the Access-Control-Expose-Headers response header with these headers.
|
||||
*/
|
||||
'exposed_headers' => [],
|
||||
|
||||
/*
|
||||
* Sets the Access-Control-Max-Age response header when > 0.
|
||||
*/
|
||||
'max_age' => 0,
|
||||
|
||||
/*
|
||||
* Sets the Access-Control-Allow-Credentials header.
|
||||
*/
|
||||
'supports_credentials' => false,
|
||||
];
|
14
package-lock.json
generated
14
package-lock.json
generated
@ -2990,9 +2990,9 @@
|
||||
}
|
||||
},
|
||||
"csv-parse": {
|
||||
"version": "4.15.0",
|
||||
"resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-4.15.0.tgz",
|
||||
"integrity": "sha512-y2wGeU/ybvUlyw6F+eanM6lxxE4JthCuHuaoTgPXdw6ImmfYXqtP0nrCLqd6Ew/a0FgPEz36y5HznI0W5oJ+cg=="
|
||||
"version": "4.15.1",
|
||||
"resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-4.15.1.tgz",
|
||||
"integrity": "sha512-TXIvRtNp0fqMJbk3yPR35bQIDzMH4khDwduElzE7Fl1wgnl25mnWYLSLqd/wS5GsDoX1rWtysivEYMNsz5jKwQ=="
|
||||
},
|
||||
"cyclist": {
|
||||
"version": "1.0.1",
|
||||
@ -7723,9 +7723,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"sass": {
|
||||
"version": "1.32.5",
|
||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.32.5.tgz",
|
||||
"integrity": "sha512-kU1yJ5zUAmPxr7f3q0YXTAd1oZjSR1g3tYyv+xu0HZSl5JiNOaE987eiz7wCUvbm4I9fGWGU2TgApTtcP4GMNQ==",
|
||||
"version": "1.32.6",
|
||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.32.6.tgz",
|
||||
"integrity": "sha512-1bcDHDcSqeFtMr0JXI3xc/CXX6c4p0wHHivJdru8W7waM7a1WjKMm4m/Z5sY7CbVw4Whi2Chpcw6DFfSWwGLzQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chokidar": ">=2.0.0 <4.0.0"
|
||||
@ -7806,7 +7806,7 @@
|
||||
"dev": true
|
||||
},
|
||||
"selectize": {
|
||||
"version": "github:selectize/selectize.js#7cc5112ce8cade6e2e315c7a12743e583799a94e",
|
||||
"version": "github:selectize/selectize.js#0101a22ce26f71a739568d3df276ecf3b0435b32",
|
||||
"from": "github:selectize/selectize.js#master",
|
||||
"requires": {
|
||||
"jquery-ui": "^1.12.1",
|
||||
|
@ -16,7 +16,7 @@
|
||||
"cross-env": "^6.0.3",
|
||||
"laravel-mix": "^5.0.9",
|
||||
"resolve-url-loader": "^3.1.2",
|
||||
"sass": "^1.32.5",
|
||||
"sass": "^1.32.6",
|
||||
"sass-loader": "^8.0.2",
|
||||
"vue-template-compiler": "^2.6.12"
|
||||
},
|
||||
|
@ -17,7 +17,6 @@ post_max_size = 20M
|
||||
; Uncomment the zend_extension line to enable xDebug
|
||||
; -------
|
||||
|
||||
;zend_extension = /opt/bitnami/php/lib/php/extensions/xdebug.so
|
||||
xdebug.idekey = "phpstorm"
|
||||
xdebug.remote_enable = 1
|
||||
xdebug.remote_host = docker.for.mac.localhost
|
||||
@ -35,10 +34,6 @@ xdebug.profiler_enable_trigger=1
|
||||
xdebug.profiler_enable_trigger_value=1
|
||||
xdebug.profiler_append = 1
|
||||
|
||||
; PCov
|
||||
; -------
|
||||
;extension=pcov.so
|
||||
|
||||
; opcache
|
||||
; -------
|
||||
|
||||
|
@ -23,7 +23,5 @@ return [
|
||||
|
||||
'no_results' => 'No results found.',
|
||||
|
||||
'validation_query_missing' => 'A search query must be present if no lists or tags were provided.',
|
||||
'validation_lists_missing' => 'A list must be present if no query or some tags were provided.',
|
||||
'validation_tags_missing' => 'A tag must be present if no query or some lists were provided.',
|
||||
'validation_query_missing' => 'You must either enter a search query, or select a list, a tag or enable searching for broken links.',
|
||||
];
|
||||
|
@ -21,11 +21,13 @@ class SearchLinksTest extends ApiTestCase
|
||||
public function testWithoutQuery(): void
|
||||
{
|
||||
$response = $this->getJsonAuthorized('api/v1/search/links');
|
||||
$msg = 'You must either enter a search query, or select a list, a tag or enable searching for broken links.';
|
||||
|
||||
$response->assertJsonValidationErrors([
|
||||
'query' => 'A search query must be present if no lists or tags were provided.',
|
||||
'only_lists' => 'A list must be present if no query or some tags were provided.',
|
||||
'only_tags' => 'A tag must be present if no query or some lists were provided.',
|
||||
'query' => $msg,
|
||||
'only_lists' => $msg,
|
||||
'only_tags' => $msg,
|
||||
'broken_only' => $msg,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -12,10 +12,8 @@ use Tests\TestCase;
|
||||
class HtmlMetaHelperTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test the titleFromURL() helper funtion with a valid URL
|
||||
* Will return the title of the Google frontpage: "Google"
|
||||
*
|
||||
* @return void
|
||||
* Test the titleFromURL() helper function with a valid URL
|
||||
* Will return the title of the DuckDuckGo frontpage: "DuckDuckGo"
|
||||
*/
|
||||
public function testTitleFromValidURL(): void
|
||||
{
|
||||
@ -40,10 +38,8 @@ class HtmlMetaHelperTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the titleFromURL() helper funtion with a valid URL
|
||||
* Will return the title of the Google frontpage: "Google"
|
||||
*
|
||||
* @return void
|
||||
* Test the titleFromURL() helper function with a valid URL
|
||||
* Will return the title of the DuckDuckGo frontpage: "DuckDuckGo".
|
||||
*/
|
||||
public function testAlternativeDescriptionFromValidURL(): void
|
||||
{
|
||||
@ -67,10 +63,8 @@ class HtmlMetaHelperTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the titleFromURL() helper funtion with an invalid URL
|
||||
* Will geturn just the host of the given URL
|
||||
*
|
||||
* @return void
|
||||
* Test the titleFromURL() helper function with an invalid URL
|
||||
* Will return just the host of the given URL.
|
||||
*/
|
||||
public function testTitleFromInvalidURL(): void
|
||||
{
|
||||
@ -88,10 +82,8 @@ class HtmlMetaHelperTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the titleFromURL() helper funtion with an invalid URL
|
||||
* Will geturn just the host of the given URL
|
||||
*
|
||||
* @return void
|
||||
* Test the titleFromURL() helper function with an invalid URL
|
||||
* Will return just the host of the given URL.
|
||||
*/
|
||||
public function testTitleFromURLwithoutProtocol(): void
|
||||
{
|
||||
@ -109,7 +101,7 @@ class HtmlMetaHelperTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the titleFromURL() helper funtion with an valid URL that returns
|
||||
* Test the titleFromURL() helper function with an valid URL that returns
|
||||
* a certificate error.
|
||||
* Will return just the host of the given URL and issue a new flash message.
|
||||
*/
|
||||
@ -139,7 +131,7 @@ class HtmlMetaHelperTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the titleFromURL() helper funtion with an valid URL that is not
|
||||
* Test the titleFromURL() helper function with an valid URL that is not
|
||||
* accessible due to connection errors, such as a refused connection for
|
||||
* a specific port.
|
||||
* Will return just the host of the given URL and issue a new flash message.
|
||||
@ -217,4 +209,28 @@ class HtmlMetaHelperTest extends TestCase
|
||||
$this->assertArrayHasKey('title', $result);
|
||||
$this->assertEquals('duckduckgo.com', $result['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the titleFromURL() helper function with a valid URL.
|
||||
* Should return the host as the title because conversion is not possible
|
||||
* in this case.
|
||||
*/
|
||||
public function testMetaEncodingWithIncorrectCharset(): void
|
||||
{
|
||||
$testHtml = '<!DOCTYPE html><head>' .
|
||||
'<title>DuckDuckGo</title>' .
|
||||
'<meta charset="utf-8,windows-1251">' .
|
||||
'</head></html>';
|
||||
|
||||
Http::fake([
|
||||
'*' => Http::response($testHtml, 200),
|
||||
]);
|
||||
|
||||
$url = 'https://duckduckgo.com/';
|
||||
$result = HtmlMeta::getFromUrl($url);
|
||||
|
||||
$this->assertArrayHasKey('title', $result);
|
||||
$this->assertEquals('duckduckgo.com', $result['title']);
|
||||
$this->assertTrue($result['success']);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user