You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because Rules::resolve try to comply to PublicSuffix List algorithm some
exception are not always caught
Rules::getPublicSuffix is more strict than Rules::resolve and only returns the
public suffix information for a given domain.
The Domain and PublicSuffix value object now implements two modifiers
::toUnicode and ::toAscii to convers their value according to IDN UTS 46
algorithm. Domain names are still not validated but if the conversion can
not be perform an Exception is thrown.
Copy file name to clipboardExpand all lines: README.md
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,10 +64,17 @@ final class Rules
64
64
public static function createFromPath(string $path, $context = null): self
65
65
public static function createFromString(string $content): self
66
66
public function __construct(array $rules)
67
+
public function supports(string $section): bool
68
+
public function getPublicSuffix(string $domain = null, string $section = self::ALL_DOMAINS): PublicSuffix
67
69
public function resolve(string $domain = null, string $section = self::ALL_DOMAINS): Domain
68
70
}
69
71
~~~
70
72
73
+
**NEW IN VERSION 5.2:**
74
+
75
+
-`Rules::supports` returns a boolean to tell whether the specific section is present in the `Rules` object;
76
+
-`Rules::getPublicSuffix` returns a `PublicSuffix` object determined from the `Rules` object;
77
+
71
78
**NEW IN VERSION 5.1:**
72
79
73
80
-`Rules::createFromString` expects a string content which follows [the PSL format](https://publicsuffix.org/list/#list-format);
@@ -104,9 +111,18 @@ final class Domain implements JsonSerializable
104
111
public function isKnown(): bool;
105
112
public function isICANN(): bool;
106
113
public function isPrivate(): bool;
114
+
public function getSection(): string;
115
+
public function toUnicode(): self;
116
+
public function toAscii(): self;
107
117
}
108
118
~~~
109
119
120
+
**NEW IN VERSION 5.2:**
121
+
122
+
-`Domain::getSection` returns the section string name if presents else returns an empty string;
123
+
-`Domain::toUnicode` returns an instance with the domain converted to its unicode representation;
124
+
-`Domain::toAscii` returns an instance with the domain converted to its ascii representation;
125
+
110
126
**THIS EXAMPLE ILLUSTRATES HOW THE OBJECT WORK BUT SHOULD BE AVOIDED IN PRODUCTON**
111
127
112
128
~~~php
@@ -169,6 +185,28 @@ If the domain name or some of its part are seriously malformed or unrecognized,
169
185
-`Pdp\Domain::isICANN` returns `true` if the public suffix is found using a PSL which includes the ICANN DOMAINS section;
170
186
-`Pdp\Domain::isPrivate` returns `true` if the public suffix is found using a PSL which includes the PRIVATE DOMAINS section;
171
187
188
+
The `Rules::getPublicSuffix` method expects the same arguments as `Rules::resolve` but returns a `Pdp\PublicSuffix` object instead.
189
+
190
+
~~~php
191
+
<?php
192
+
193
+
final class PublicSuffix implements Countable, JsonSerializable
194
+
{
195
+
public function getContent(): ?string
196
+
public function isKnown(): bool;
197
+
public function isICANN(): bool;
198
+
public function isPrivate(): bool;
199
+
public function getSection(): string;
200
+
public function toUnicode(): self;
201
+
public function toAscii(): self;
202
+
}
203
+
~~~
204
+
205
+
While `Rules::resolve` will only throws an exception if the section value is invalid, the `Rules::getPublicSuffix` is more restrictive and will additionnally throw if:
206
+
207
+
- If the Domain is invalid or seriously malformed
208
+
- If the PublicSuffix can not be normalized and converted using the domain encoding.
209
+
172
210
**WARNING:**
173
211
174
212
**The `Pdp\Rules::resolve` does not validate the submitted host. You are require to use a host validator prior to using this library.**
0 commit comments