@@ -42,33 +42,24 @@ function pre_http_request( $flag, $parsed_args, $url ) {
4242
4343	$ blocklist
4444	if  ( is_file ( $ blocklist_fileis_readable ( $ blocklist_file
45- 		$ blocklistfile ( $ blocklist_file
45+ 		$ blocklistfile ( $ blocklist_file,  FILE_IGNORE_NEW_LINES  |  FILE_SKIP_EMPTY_LINES  );
4646	}
4747
48- 	/** 
49- 	 * Here we get the file values and they have a \n at the end. 
50- 	 * Remove all useless caracters. 
51- 	 */ 
52- 	$ blocklistarray_map ( 'trim ' , $ blocklist
53- 	$ blocklistarray_filter ( $ blocklist
54- 5548	$ blocklistapply_filters ( 'wp_http_blocklist ' , $ blocklist
56- 	$ blocklistarray_unique ( $ blocklist
49+ 	$ blocklistarray_unique ( array_filter (  array_map (  ' trim ' ,  $ blocklist ) )  );
5750
5851	if  ( empty ( $ blocklist
5952		return  $ flag
6053	}
6154
62- 	foreach  ( $ blocklistas  $ blocklist_domain
63- 		if  ( $ request_host$ blocklist_domain
64- 			// translators: First is the host blocked, second is the full url called 
65- 			$ responsenew  \WP_Error ( 'http_request_blocked ' , sprintf ( __ ( 'Host %1$s is blocked from a deny list. ' , 'wp-http-blocklist '  ), $ request_host
66- 			/** This action is documented in wp-includes/class-http.php */ 
67- 			do_action ( 'http_api_debug ' , $ response'response ' , 'Requests ' , $ parsed_args$ url
68- 69- 			return  $ response
70- 		}
55+ 	if  ( false  === array_search ( $ request_host$ blocklist
56+ 		return  $ flag
7157	}
7258
73- 	return  $ flag
59+ 	// translators: First is the host blocked, second is the full url called 
60+ 	$ responsenew  \WP_Error ( 'http_request_blocked ' , sprintf ( __ ( 'Host %1$s is blocked from a deny list. ' , 'wp-http-blocklist '  ), $ request_host
61+ 	/** This action is documented in wp-includes/class-http.php */ 
62+ 	do_action ( 'http_api_debug ' , $ response'response ' , 'Requests ' , $ parsed_args$ url
63+ 64+ 	return  $ response
7465}
0 commit comments