Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
anupsv committed Sep 13, 2024
1 parent 91ccf7f commit aa430ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 7 additions & 4 deletions keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"golang.org/x/text/unicode/norm"
"io/ioutil"
"os"
"path/filepath"
"unicode"
Expand Down Expand Up @@ -165,7 +164,8 @@ func KeystoreCryptoFromJSON(data map[string]interface{}) (*KeystoreCrypto, error

// FromFile reads a keystore from a file
func (ks *Keystore) FromFile(path string) error {
fileData, err := ioutil.ReadFile(path)
cleanedPath := filepath.Clean(path)
fileData, err := os.ReadFile(cleanedPath)
if err != nil {
return err
}
Expand Down Expand Up @@ -319,8 +319,11 @@ func (ks *Keystore) ToJSON() (string, error) {

// Save writes the Keystore to a file in JSON format
func (ks *Keystore) Save(fileFolder string) error {
filePath := filepath.Join(fileFolder, ks.UUID+".json")
file, err := os.Create(filePath)
cleanedFileFolder := filepath.Clean(fileFolder)
filePath := filepath.Join(cleanedFileFolder, ks.UUID+".json")

cleanedFilePath := filepath.Clean(fileFolder)
file, err := os.Create(cleanedFilePath)
if err != nil {
return err
}
Expand Down
7 changes: 5 additions & 2 deletions mnemonic.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ import (
// - []string: A slice of words from the wordlist.
// - error: An error object if the wordlist file cannot be read.
func getWordList(language, path string) ([]string, error) {
filePath := filepath.Join(path, fmt.Sprintf("%s.txt", language))
file, err := os.Open(filePath)
cleanLanguageFileName := filepath.Clean(fmt.Sprintf("%s.txt", language))
filePath := filepath.Join(path, cleanLanguageFileName)

cleanFilePath := filepath.Clean(filePath)
file, err := os.Open(cleanFilePath)
if err != nil {
return nil, fmt.Errorf("failed to open wordlist file: %v", err)
}
Expand Down

0 comments on commit aa430ea

Please sign in to comment.