feat: add regex check. related to #26
- if user calls Dial method with an url that does not URL encoded, return error to remind.
This commit is contained in:
parent
b6b1f4a437
commit
5318f2ad7b
@ -14,6 +14,7 @@ import (
|
||||
"log"
|
||||
"net"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -521,6 +522,11 @@ func (client *RTSPClient) parseURL(rawURL string) error {
|
||||
}
|
||||
username := l.User.Username()
|
||||
password, _ := l.User.Password()
|
||||
pattern := `[ !#$%&'()*+,/:;=?@\[\]]`
|
||||
re := regexp.MustCompile(pattern)
|
||||
if re.MatchString(username) || re.MatchString(password) {
|
||||
return errors.New("please url encode username and password")
|
||||
}
|
||||
l.User = nil
|
||||
if l.Port() == "" {
|
||||
l.Host = fmt.Sprintf("%s:%s", l.Host, "554")
|
||||
|
Loading…
Reference in New Issue
Block a user