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:
GyeongHo Kim 2024-07-30 22:27:53 +09:00
parent b6b1f4a437
commit 5318f2ad7b

View File

@ -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")