@@ -328,20 +328,12 @@ pub struct LSPS5WebhookUrl(LSPSUrl);
328328impl LSPS5WebhookUrl {
329329 /// Create a new LSPS5 webhook URL.
330330 pub fn new ( url : UntrustedString ) -> Result < Self , LSPS5Error > {
331- let parsed_url = LSPSUrl :: parse ( url. 0 . clone ( ) )
332- . map_err ( |_e| LSPS5ProtocolError :: UrlParse ( "Error parsing URL" . to_string ( ) ) ) ?;
333- if parsed_url. url_length ( ) > MAX_WEBHOOK_URL_LENGTH {
331+ let raw_url = url. to_string ( ) ;
332+ if raw_url. len ( ) > MAX_WEBHOOK_URL_LENGTH {
334333 return Err ( LSPS5ProtocolError :: WebhookUrlTooLong . into ( ) ) ;
335334 }
336- if !parsed_url. is_https ( ) {
337- return Err ( LSPS5ProtocolError :: UnsupportedProtocol . into ( ) ) ;
338- }
339- if !parsed_url. is_public ( ) {
340- return Err ( LSPS5ProtocolError :: UrlParse (
341- "Webhook URL must be a public URL" . to_string ( ) ,
342- )
343- . into ( ) ) ;
344- }
335+ let parsed_url = LSPSUrl :: parse ( url. 0 ) ?;
336+
345337 Ok ( Self ( parsed_url) )
346338 }
347339
@@ -807,13 +799,14 @@ mod tests {
807799 #[ test]
808800 fn test_url_security_validation ( ) {
809801 let urls_that_should_throw = [
810- "https://10.0.0.1/webhook" ,
811- "https://192.168.1.1/webhook" ,
812- "https://172.16.0.1/webhook" ,
813- "https://172.31.255.255/webhook" ,
814- "https://localhost/webhook" ,
815802 "test-app" ,
816803 "http://example.com/webhook" ,
804+ "ftp://example.com/webhook" ,
805+ "ws://example.com/webhook" ,
806+ "ws+unix://example.com/webhook" ,
807+ "ws+unix:/example.com/webhook" ,
808+ "ws+unix://example.com/webhook?param=value" ,
809+ "ws+unix:/example.com/webhook?param=value" ,
817810 ] ;
818811
819812 for url_str in urls_that_should_throw. iter ( ) {
0 commit comments