fixes old UTF8 tags in uboot
This commit is contained in:
parent
fcc5a36ad0
commit
d4f9878298
28
config.go
28
config.go
|
@ -8,6 +8,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"go.wit.com/lib/protobuf/bugpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -26,6 +27,19 @@ func (all *Repos) ConfigSave() error {
|
||||||
data, err := all.Marshal()
|
data, err := all.Marshal()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("gitpb proto.Marshal() failed len", len(data), err)
|
log.Info("gitpb proto.Marshal() failed len", len(data), err)
|
||||||
|
// often this is because strings have invalid UTF-8. This should probably be fixed in the protobuf code
|
||||||
|
if err := all.tryValidate(); err != nil {
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
// re-attempt Marshal() here
|
||||||
|
data, err = all.Marshal()
|
||||||
|
if err == nil {
|
||||||
|
// validate & sanitize strings worked
|
||||||
|
log.Info("gitpb.ConfigSave() repos.Marshal() worked len", len(all.Repos), "repos")
|
||||||
|
configWrite("repos.pb", data)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Info("gitpb.ConfigSave() repos.Marshal() worked len", len(all.Repos), "repos")
|
log.Info("gitpb.ConfigSave() repos.Marshal() worked len", len(all.Repos), "repos")
|
||||||
|
@ -33,6 +47,20 @@ func (all *Repos) ConfigSave() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (all *Repos) tryValidate() error {
|
||||||
|
|
||||||
|
err := bugpb.ValidateProtoUTF8(all)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Protobuf UTF-8 validation failed: %v\n", err)
|
||||||
|
}
|
||||||
|
if err := bugpb.SanitizeProtoUTF8(all); err != nil {
|
||||||
|
log.Warn("Sanitation failed:", err)
|
||||||
|
// log.Fatalf("Sanitization failed: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// load the repos.pb file. I shouldn't really matter if this
|
// load the repos.pb file. I shouldn't really matter if this
|
||||||
// fails. the file should be autogenerated. This is used
|
// fails. the file should be autogenerated. This is used
|
||||||
// locally just for speed
|
// locally just for speed
|
||||||
|
|
Loading…
Reference in New Issue