Skip to content

Commit 8ca2aa5

Browse files
committed
TibiaBoostableBossesOverview: validate improper input
1 parent 21041e6 commit 8ca2aa5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/TibiaBoostableBossesOverview.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"errors"
45
"net/http"
56
"strings"
67

@@ -50,10 +51,19 @@ func TibiaBoostableBossesOverviewImpl(BoxContentHTML string) (BoostableBossesOve
5051
bodyIdx := strings.Index(
5152
BoxContentHTML, bodyIndexer,
5253
)
54+
55+
if bodyIdx == -1 {
56+
return BoostableBossesOverviewResponse{}, errors.New("[error] body passd to TibiaBoostableBossesOverviewImpl is not valid")
57+
}
58+
5359
endBodyIdx := strings.Index(
5460
BoxContentHTML[bodyIdx:], endBodyIndexer,
5561
) + bodyIdx + len(endBodyIndexer)
5662

63+
if endBodyIdx == -1 {
64+
return BoostableBossesOverviewResponse{}, errors.New("[error] body passd to TibiaBoostableBossesOverviewImpl is not valid")
65+
}
66+
5767
data := BoxContentHTML[bodyIdx:endBodyIdx]
5868

5969
var (

0 commit comments

Comments
 (0)