parent
ca322a1456
commit
f6b889b53b
|
@ -617,7 +617,7 @@ func validateURLString(data string) bool {
|
|||
|
||||
// ? - There should only be one : and that's only if the URL is on a non-standard port. Same for ?s.
|
||||
for ; datalen > i; i++ {
|
||||
if data[i] != '\\' && data[i] != '_' && data[i] != ':' && data[i] != '?' && data[i] != '&' && data[i] != '=' && data[i] != ';' && data[i] != '@' && !(data[i] > 44 && data[i] < 58) && !(data[i] > 64 && data[i] < 91) && !(data[i] > 96 && data[i] < 123) {
|
||||
if data[i] != '\\' && data[i] != '_' && data[i] != ':' && data[i] != '?' && data[i] != '&' && data[i] != '=' && data[i] != ';' && data[i] != '@' && data[i] != '#' && !(data[i] > 44 && data[i] < 58) && !(data[i] > 64 && data[i] < 91) && !(data[i] > 96 && data[i] < 123) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -643,7 +643,7 @@ func validatedURLBytes(data []byte) (url []byte) {
|
|||
|
||||
// ? - There should only be one : and that's only if the URL is on a non-standard port. Same for ?s.
|
||||
for ; datalen > i; i++ {
|
||||
if data[i] != '\\' && data[i] != '_' && data[i] != ':' && data[i] != '?' && data[i] != '&' && data[i] != '=' && data[i] != ';' && data[i] != '@' && !(data[i] > 44 && data[i] < 58) && !(data[i] > 64 && data[i] < 91) && !(data[i] > 96 && data[i] < 123) {
|
||||
if data[i] != '\\' && data[i] != '_' && data[i] != ':' && data[i] != '?' && data[i] != '&' && data[i] != '=' && data[i] != ';' && data[i] != '@' && data[i] != '#' && !(data[i] > 44 && data[i] < 58) && !(data[i] > 64 && data[i] < 91) && !(data[i] > 96 && data[i] < 123) {
|
||||
return InvalidURL
|
||||
}
|
||||
}
|
||||
|
@ -672,7 +672,7 @@ func PartialURLString(data string) (url []byte) {
|
|||
|
||||
// ? - There should only be one : and that's only if the URL is on a non-standard port. Same for ?s.
|
||||
for ; end >= i; i++ {
|
||||
if data[i] != '\\' && data[i] != '_' && data[i] != ':' && data[i] != '?' && data[i] != '&' && data[i] != '=' && data[i] != ';' && data[i] != '@' && !(data[i] > 44 && data[i] < 58) && !(data[i] > 64 && data[i] < 91) && !(data[i] > 96 && data[i] < 123) {
|
||||
if data[i] != '\\' && data[i] != '_' && data[i] != ':' && data[i] != '?' && data[i] != '&' && data[i] != '=' && data[i] != ';' && data[i] != '@' && data[i] != '#' && !(data[i] > 44 && data[i] < 58) && !(data[i] > 64 && data[i] < 91) && !(data[i] > 96 && data[i] < 123) {
|
||||
end = i
|
||||
}
|
||||
}
|
||||
|
@ -701,7 +701,7 @@ func PartialURLStringLen(data string) int {
|
|||
|
||||
// ? - There should only be one : and that's only if the URL is on a non-standard port. Same for ?s.
|
||||
for ; datalen > i; i++ {
|
||||
if data[i] != '\\' && data[i] != '_' && data[i] != ':' && data[i] != '?' && data[i] != '&' && data[i] != '=' && data[i] != ';' && data[i] != '@' && !(data[i] > 44 && data[i] < 58) && !(data[i] > 64 && data[i] < 91) && !(data[i] > 96 && data[i] < 123) {
|
||||
if data[i] != '\\' && data[i] != '_' && data[i] != ':' && data[i] != '?' && data[i] != '&' && data[i] != '=' && data[i] != ';' && data[i] != '@' && data[i] != '#' && !(data[i] > 44 && data[i] < 58) && !(data[i] > 64 && data[i] < 91) && !(data[i] > 96 && data[i] < 123) {
|
||||
//log.Print("Bad Character: ", data[i])
|
||||
return i
|
||||
}
|
||||
|
|
|
@ -1259,6 +1259,10 @@ func TestParser(t *testing.T) {
|
|||
msgList = addMETri(msgList, "//"+common.Site.URL+"\n", "<a href='//"+common.Site.URL+"'>//"+common.Site.URL+"</a><br>")
|
||||
msgList = addMETri(msgList, "//"+common.Site.URL+"\n//"+common.Site.URL, "<a href='//"+common.Site.URL+"'>//"+common.Site.URL+"</a><br><a href='//"+common.Site.URL+"'>//"+common.Site.URL+"</a>")
|
||||
|
||||
msgList = addMETri(msgList, "#tid-1", "<a href='/topic/1'>#tid-1</a>")
|
||||
msgList = addMETri(msgList, "https://github.com/Azareal/Gosora/#tid-1", "<a href='https://github.com/Azareal/Gosora/#tid-1'>https://github.com/Azareal/Gosora/#tid-1</a>")
|
||||
msgList = addMETri(msgList, "#fid-1", "<a href='/forum/1'>#fid-1</a>")
|
||||
|
||||
for _, item := range msgList {
|
||||
res = common.ParseMessage(item.Msg, 1, "forums")
|
||||
if res != item.Expects {
|
||||
|
@ -1267,7 +1271,6 @@ func TestParser(t *testing.T) {
|
|||
}
|
||||
t.Error("Testing string '" + item.Msg + "'")
|
||||
t.Error("Bad output:", "'"+res+"'")
|
||||
//t.Error("Ouput in bytes:", []byte(res))
|
||||
t.Error("Expected:", "'"+item.Expects+"'")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue