fix crash on parsing of empty lines, update drone and gitignore
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9314f4397d
commit
7993c9f7ed
@ -26,7 +26,7 @@ steps:
|
|||||||
secret_key:
|
secret_key:
|
||||||
from_secret: MINIO_SECRET_KEY
|
from_secret: MINIO_SECRET_KEY
|
||||||
endpoint: https://minio.burble.dn42
|
endpoint: https://minio.burble.dn42
|
||||||
region: uk-lon3
|
region: fr-par1
|
||||||
path_style: true
|
path_style: true
|
||||||
source: dn42regsrv
|
source: dn42regsrv
|
||||||
target: /dn42regsrv/${DRONE_BRANCH}
|
target: /dn42regsrv/${DRONE_BRANCH}
|
||||||
@ -40,7 +40,7 @@ steps:
|
|||||||
secret_key:
|
secret_key:
|
||||||
from_secret: MINIO_SECRET_KEY
|
from_secret: MINIO_SECRET_KEY
|
||||||
endpoint: https://minio.burble.dn42
|
endpoint: https://minio.burble.dn42
|
||||||
region: uk-lon3
|
region: fr-par1
|
||||||
path_style: true
|
path_style: true
|
||||||
source: staticroot.tar.gz
|
source: staticroot.tar.gz
|
||||||
target: /dn42regsrv/${DRONE_BRANCH}
|
target: /dn42regsrv/${DRONE_BRANCH}
|
||||||
|
68
.gitignore
vendored
Normal file
68
.gitignore
vendored
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
# ---> Go
|
||||||
|
# Binaries for programs and plugins
|
||||||
|
*.exe
|
||||||
|
*.exe~
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Test binary, built with `go test -c`
|
||||||
|
*.test
|
||||||
|
|
||||||
|
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||||
|
*.out
|
||||||
|
|
||||||
|
# Dependency directories (remove the comment below to include it)
|
||||||
|
# vendor/
|
||||||
|
|
||||||
|
# ---> Emacs
|
||||||
|
# -*- mode: gitignore; -*-
|
||||||
|
*~
|
||||||
|
\#*\#
|
||||||
|
/.emacs.desktop
|
||||||
|
/.emacs.desktop.lock
|
||||||
|
*.elc
|
||||||
|
auto-save-list
|
||||||
|
tramp
|
||||||
|
.\#*
|
||||||
|
|
||||||
|
# Org-mode
|
||||||
|
.org-id-locations
|
||||||
|
*_archive
|
||||||
|
|
||||||
|
# flymake-mode
|
||||||
|
*_flymake.*
|
||||||
|
|
||||||
|
# eshell files
|
||||||
|
/eshell/history
|
||||||
|
/eshell/lastdir
|
||||||
|
|
||||||
|
# elpa packages
|
||||||
|
/elpa/
|
||||||
|
|
||||||
|
# reftex files
|
||||||
|
*.rel
|
||||||
|
|
||||||
|
# AUCTeX auto folder
|
||||||
|
/auto/
|
||||||
|
|
||||||
|
# cask packages
|
||||||
|
.cask/
|
||||||
|
dist/
|
||||||
|
|
||||||
|
# Flycheck
|
||||||
|
flycheck_*.el
|
||||||
|
|
||||||
|
# server auth directory
|
||||||
|
/server/
|
||||||
|
|
||||||
|
# projectiles files
|
||||||
|
.projectile
|
||||||
|
|
||||||
|
# directory configuration
|
||||||
|
.dir-locals.el
|
||||||
|
|
||||||
|
# network security
|
||||||
|
/network-security.data
|
||||||
|
|
||||||
|
dn42regsrv
|
79
registry.go
79
registry.go
@ -348,56 +348,59 @@ func loadAttributes(path string) []*RegAttribute {
|
|||||||
|
|
||||||
line := strings.TrimRight(scanner.Text(), "\r\n")
|
line := strings.TrimRight(scanner.Text(), "\r\n")
|
||||||
|
|
||||||
|
// skip empty lines
|
||||||
|
if len(line) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// lines starting with '+' denote an empty line
|
// lines starting with '+' denote an empty line
|
||||||
if line[0] == '+' {
|
if line[0] == '+' {
|
||||||
|
|
||||||
// concatenate a \n on to the previous attribute value
|
// concatenate a \n on to the previous attribute value
|
||||||
attributes[len(attributes)-1].RawValue += "\n"
|
attributes[len(attributes)-1].RawValue += "\n"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
// look for a : separator in the first 20 characters
|
||||||
|
ix := strings.IndexByte(line, ':')
|
||||||
|
if ix == -1 || ix >= 20 {
|
||||||
|
// couldn't find one
|
||||||
|
|
||||||
// look for a : separator in the first 20 characters
|
if len(line) <= 20 {
|
||||||
ix := strings.IndexByte(line, ':')
|
// hmmm, the line was shorter than 20 characters
|
||||||
if ix == -1 || ix >= 20 {
|
// something is amiss
|
||||||
// couldn't find one
|
|
||||||
|
|
||||||
if len(line) <= 20 {
|
log.WithFields(log.Fields{
|
||||||
// hmmm, the line was shorter than 20 characters
|
"length": len(line),
|
||||||
// something is amiss
|
"path": path,
|
||||||
|
"line": line,
|
||||||
|
}).Warn("Short line detected")
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
|
||||||
"length": len(line),
|
|
||||||
"path": path,
|
|
||||||
"line": line,
|
|
||||||
}).Warn("Short line detected")
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// line is a continuation of the previous line, so
|
|
||||||
// concatenate the value on to the previous attribute value
|
|
||||||
attributes[len(attributes)-1].RawValue +=
|
|
||||||
"\n" + string(line[20:])
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// found a key and : separator
|
|
||||||
|
|
||||||
// is there actually a value ?
|
// line is a continuation of the previous line, so
|
||||||
var value string
|
// concatenate the value on to the previous attribute value
|
||||||
if len(line) <= 20 {
|
attributes[len(attributes)-1].RawValue +=
|
||||||
// blank value
|
"\n" + string(line[20:])
|
||||||
value = ""
|
|
||||||
} else {
|
|
||||||
value = string(line[20:])
|
|
||||||
}
|
|
||||||
|
|
||||||
// create a new attribute
|
|
||||||
a := &RegAttribute{
|
|
||||||
Key: string(line[:ix]),
|
|
||||||
RawValue: value,
|
|
||||||
}
|
|
||||||
attributes = append(attributes, a)
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// found a key and : separator
|
||||||
|
|
||||||
|
// is there actually a value ?
|
||||||
|
var value string
|
||||||
|
if len(line) <= 20 {
|
||||||
|
// blank value
|
||||||
|
value = ""
|
||||||
|
} else {
|
||||||
|
value = string(line[20:])
|
||||||
|
}
|
||||||
|
|
||||||
|
// create a new attribute
|
||||||
|
a := &RegAttribute{
|
||||||
|
Key: string(line[:ix]),
|
||||||
|
RawValue: value,
|
||||||
|
}
|
||||||
|
attributes = append(attributes, a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user