Skip to content

Commit fa1db0f

Browse files
authored
Sanitize certain strings containing html encoding (#14)
* Replace double quote HTML entities code with single quotes * Extract helper function
1 parent 2ae1e3a commit fa1db0f

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/TibiaSpellsOverviewV3.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func TibiaSpellsOverviewV3(c *gin.Context) {
127127
SpellsData = append(SpellsData, Spell{
128128
Name: subma1[0][2],
129129
Spell: subma1[0][1],
130-
Formula: subma1[0][3],
130+
Formula: TibiaDataSanitizeString(subma1[0][3]),
131131
Level: TibiadataStringToIntegerV3(subma1[0][6]),
132132
Mana: TibiadataStringToIntegerV3(subma1[0][7]),
133133
Price: TibiadataStringToIntegerV3(subma1[0][8]),

src/TibiaSpellsSpellV3.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func TibiaSpellsSpellV3(c *gin.Context) {
141141

142142
// Formula
143143
if WorldsInformationLeftColumn == "Formula" {
144-
SpellsInfoFormula = WorldsInformationRightColumn
144+
SpellsInfoFormula = TibiaDataSanitizeString(WorldsInformationRightColumn)
145145
}
146146

147147
// Vocation
@@ -238,6 +238,7 @@ func TibiaSpellsSpellV3(c *gin.Context) {
238238

239239
// City
240240
if WorldsInformationLeftColumn == "City" {
241+
WorldsInformationRightColumn = TibiaDataSanitizeString(WorldsInformationRightColumn)
241242
SpellsInfoCity = strings.Split(WorldsInformationRightColumn, ", ")
242243
}
243244

src/webserver.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,11 @@ func isEnvExist(key string) bool {
457457
return false
458458
}
459459

460+
func TibiaDataSanitizeString(data string) string {
461+
data = html.UnescapeString(data)
462+
return strings.ReplaceAll(data, "\"", "'")
463+
}
464+
460465
// getEnv func - read an environment or return a default value
461466
func getEnv(key string, defaultVal string) string {
462467
if value, exists := os.LookupEnv(key); exists {

0 commit comments

Comments
 (0)