File tree Expand file tree Collapse file tree 4 files changed +18
-2
lines changed
Expand file tree Collapse file tree 4 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " pydomainextractor"
3- version = " 0.13.4 "
3+ version = " 0.13.5 "
44authors = [" Gal Ben David <gal@intsights.com>" ]
55edition = " 2021"
66description = " A blazingly fast domain extraction library written in Rust"
Original file line number Diff line number Diff line change 11[project ]
22name = " pydomainextractor"
3- version = " 0.13.4 "
3+ version = " 0.13.5 "
44description = " A blazingly fast domain extraction library written in Rust"
55authors = [
66 {email = " gal@intsights.com" },
Original file line number Diff line number Diff line change @@ -254,6 +254,9 @@ impl DomainExtractor {
254254 ) ;
255255 }
256256
257+ if url_str. len ( ) > 255 {
258+ return Err ( PyValueError :: new_err ( "url is invalid: too long" ) ) ;
259+ }
257260 let mut domain_string = unsafe {
258261 DomainString :: from_str_unchecked ( url_str)
259262 } ;
Original file line number Diff line number Diff line change @@ -301,6 +301,14 @@ def test_syntactic_invalid_domains(
301301 ):
302302 self .domain_extractor .extract ('com.' )
303303
304+ def test_domain_too_long (
305+ self ,
306+ ):
307+ with self .assertRaises (
308+ expected_exception = ValueError ,
309+ ):
310+ self .domain_extractor .extract (f'{ "very-long" * 255 } .com' )
311+
304312 def test_extract_from_url (
305313 self ,
306314 ):
@@ -349,6 +357,11 @@ def test_extract_from_url(
349357 ):
350358 self .domain_extractor .extract_from_url ('co.uk' )
351359
360+ with self .assertRaises (
361+ ValueError ,
362+ ):
363+ self .domain_extractor .extract_from_url (f'http://{ "domain" * 255 } co.uk:3030/some/path' )
364+
352365 self .assertEqual (
353366 first = self .domain_extractor .extract_from_url ('http://www.google.com' ),
354367 second = {
You can’t perform that action at this time.
0 commit comments