This repository was archived by the owner on Apr 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-12
lines changed
app/code/Magento/Integration/Test/Unit/Model/Oauth
lib/internal/Magento/Framework/Url Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 6
6
namespace Magento \Integration \Test \Unit \Model \Oauth ;
7
7
8
8
use Magento \Framework \Url \Validator as UrlValidator ;
9
+ use Zend \Validator \Uri as ZendUriValidator ;
9
10
use Magento \Integration \Model \Oauth \Consumer \Validator \KeyLength ;
10
11
11
12
/**
@@ -84,7 +85,7 @@ protected function setUp()
84
85
85
86
$ this ->keyLengthValidator = new KeyLength ();
86
87
87
- $ this ->urlValidator = new UrlValidator ();
88
+ $ this ->urlValidator = new UrlValidator (new ZendUriValidator () );
88
89
89
90
$ this ->oauthDataMock = $ this ->createPartialMock (
90
91
\Magento \Integration \Helper \Oauth \Data::class,
Original file line number Diff line number Diff line change 11
11
*/
12
12
namespace Magento \Framework \Url ;
13
13
14
- use Zend \Uri \UriFactory ;
15
-
16
14
class Validator extends \Zend_Validate_Abstract
17
15
{
18
16
/**#@+
@@ -21,13 +19,20 @@ class Validator extends \Zend_Validate_Abstract
21
19
const INVALID_URL = 'invalidUrl ' ;
22
20
/**#@-*/
23
21
22
+ /**
23
+ * @var \Zend\Validator\Uri
24
+ */
25
+ private $ validator ;
26
+
24
27
/**
25
28
* Object constructor
26
29
*/
27
- public function __construct ()
30
+ public function __construct (\ Zend \ Validator \ Uri $ validator )
28
31
{
29
32
// set translated message template
30
33
$ this ->setMessage ((string )new \Magento \Framework \Phrase ("Invalid URL '%value%'. " ), self ::INVALID_URL );
34
+ $ this ->validator = $ validator ;
35
+ $ this ->validator ->setAllowRelative (false );
31
36
}
32
37
33
38
/**
@@ -47,14 +52,12 @@ public function isValid($value)
47
52
{
48
53
$ this ->_setValue ($ value );
49
54
50
- try {
51
- $ uri = UriFactory::factory ($ value );
52
- if ($ uri ->isValid ()) {
53
- return true ;
54
- }
55
- } catch (Exception $ e ) {/** left empty */ }
55
+ $ valid = $ this ->validator ->isValid ($ value );
56
+
57
+ if (!$ valid ) {
58
+ $ this ->_error (self ::INVALID_URL );
59
+ }
56
60
57
- $ this ->_error (self ::INVALID_URL );
58
- return false ;
61
+ return $ valid ;
59
62
}
60
63
}
You can’t perform that action at this time.
0 commit comments