mirror of
https://github.com/teacat/chaturbate-dvr.git
synced 2025-10-29 16:59:59 +00:00
Fixed #125, sanitize Username with [^a-zA-Z0-9_-] and remove whitespace
This commit is contained in:
parent
65397fb3a1
commit
8b55209273
@ -1,5 +1,10 @@
|
|||||||
package entity
|
package entity
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
// Event represents the type of event for the channel.
|
// Event represents the type of event for the channel.
|
||||||
type Event = string
|
type Event = string
|
||||||
|
|
||||||
@ -20,6 +25,11 @@ type ChannelConfig struct {
|
|||||||
CreatedAt int64 `json:"created_at"`
|
CreatedAt int64 `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ChannelConfig) Sanitize() {
|
||||||
|
c.Username = regexp.MustCompile(`[^a-zA-Z0-9_-]`).ReplaceAllString(c.Username, "")
|
||||||
|
c.Username = strings.TrimSpace(c.Username)
|
||||||
|
}
|
||||||
|
|
||||||
// ChannelInfo represents the information about a channel,
|
// ChannelInfo represents the information about a channel,
|
||||||
// mostly used for the template rendering.
|
// mostly used for the template rendering.
|
||||||
type ChannelInfo struct {
|
type ChannelInfo struct {
|
||||||
|
|||||||
@ -88,6 +88,7 @@ func (m *Manager) LoadConfig() error {
|
|||||||
|
|
||||||
// CreateChannel starts monitoring an M3U8 stream
|
// CreateChannel starts monitoring an M3U8 stream
|
||||||
func (m *Manager) CreateChannel(conf *entity.ChannelConfig, shouldSave bool) error {
|
func (m *Manager) CreateChannel(conf *entity.ChannelConfig, shouldSave bool) error {
|
||||||
|
conf.Sanitize()
|
||||||
ch := channel.New(conf)
|
ch := channel.New(conf)
|
||||||
|
|
||||||
// prevent duplicate channels
|
// prevent duplicate channels
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user