Skip to content

Commit

Permalink
additional validation of user-provided URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
avelanarius committed Oct 31, 2024
1 parent 2548a84 commit e97a153
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion quesma/quesma/config/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// SPDX-License-Identifier: Elastic-2.0
package config

import "net/url"
import (
"fmt"
"net/url"
)

type Url url.URL

Expand All @@ -15,6 +18,12 @@ func (u *Url) UnmarshalText(text []byte) error {
if err != nil {
return err
}
if len(urlValue.Scheme) == 0 {
return fmt.Errorf("URL scheme (e.g. http:// or clickhouse://) is missing from the provided URL: %s", urlValue)
}
if len(urlValue.Port()) == 0 {
return fmt.Errorf("URL port (e.g. 8123 in 'http://localhost:8123') is missing from the provided URL: %s", urlValue)
}
*u = Url(*urlValue)
return nil
}
Expand Down

0 comments on commit e97a153

Please sign in to comment.