summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-06-29 02:49:31 -0500
committerJeff Carr <[email protected]>2025-06-29 02:49:31 -0500
commitd4f9878298b9228e5767c9c5e52cf577c2754038 (patch)
tree4fc57dab79777314576467570c28d6924e9ed815
parentfcc5a36ad02869a997ad00873401d80a67a0d664 (diff)
fixes old UTF8 tags in ubootv0.0.100
-rw-r--r--config.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/config.go b/config.go
index 53cc288..7a58b94 100644
--- a/config.go
+++ b/config.go
@@ -8,6 +8,7 @@ import (
"os"
"path/filepath"
+ "go.wit.com/lib/protobuf/bugpb"
"go.wit.com/log"
)
@@ -26,6 +27,19 @@ func (all *Repos) ConfigSave() error {
data, err := all.Marshal()
if err != nil {
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
}
log.Info("gitpb.ConfigSave() repos.Marshal() worked len", len(all.Repos), "repos")
@@ -33,6 +47,20 @@ func (all *Repos) ConfigSave() error {
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
// fails. the file should be autogenerated. This is used
// locally just for speed