Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.0 #40

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
clean file paths
dana-ross committed Feb 10, 2021
commit 250fa76c69265508e7c969f2d68535355020861e
7 changes: 4 additions & 3 deletions fonts.go
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import (
"log"
"os"
"path"
"path/filepath"
"regexp"
"strings"

@@ -61,7 +62,7 @@ func LoadFont(filePath string, config Config) {
return
}

file, err := os.Open(filePath)
file, err := os.Open(filepath.Clean(filePath))
if err != nil {
log.Fatal(err)
}
@@ -166,8 +167,8 @@ func calcUniqueID(fontVariant FontVariant, config Config) string {
}

// calcFileMD5 calculates the MD5 hash of a file
func calcFileMD5(filepath string) string {
file, err := os.Open(filepath)
func calcFileMD5(filePath string) string {
file, err := os.Open(filepath.Clean(filePath))
if err != nil {
log.Fatal(err)
}
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -232,7 +232,7 @@ func uniqueInts(input []int) []int {
}

func openAccessLog(path string) *os.File {
f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) // #nosec
f, err := os.OpenFile(filepath.Clean(path), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) // #nosec
if err != nil {
log.Fatal(fmt.Sprintf("Can't open access log file: %s", err))
}