Fix crash if tags/marks contains invalid entry (#1614)
* Fix crash if tags file contains invalid entry * Fix crash if marks file contains invalid entry
This commit is contained in:
1 parent
8ee8592b91
commit
055ce47224
1 file changed
+11
-8
@@ -1868,9 +1868,12 @@ func (nav *nav) readMarks() error {
|
||||
|
||||
scanner := bufio.NewScanner(f)
|
||||
for scanner.Scan() {
|
||||
toks := strings.SplitN(scanner.Text(), ":", 2)
|
||||
if _, ok := nav.marks[toks[0]]; !ok {
|
||||
nav.marks[toks[0]] = toks[1]
|
||||
mark, path, found := strings.Cut(scanner.Text(), ":")
|
||||
if !found {
|
||||
return fmt.Errorf("invalid marks file entry: %s", scanner.Text())
|
||||
}
|
||||
if _, ok := nav.marks[mark]; !ok {
|
||||
nav.marks[mark] = path
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1923,12 +1926,12 @@ func (nav *nav) readTags() error {
|
||||
|
||||
scanner := bufio.NewScanner(f)
|
||||
for scanner.Scan() {
|
||||
text := scanner.Text()
|
||||
ind := strings.LastIndex(text, ":")
|
||||
path := text[0:ind]
|
||||
mark := text[ind+1:]
|
||||
path, tag, found := strings.Cut(scanner.Text(), ":")
|
||||
if !found {
|
||||
return fmt.Errorf("invalid tags file entry: %s", scanner.Text())
|
||||
}
|
||||
if _, ok := nav.tags[path]; !ok {
|
||||
nav.tags[path] = mark
|
||||
nav.tags[path] = tag
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user