summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.go')
-rw-r--r--config.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/config.go b/config.go
index 9d7a360..b302969 100644
--- a/config.go
+++ b/config.go
@@ -47,8 +47,27 @@ func (all *Repos) ConfigSave() error {
return nil
}
-func (all *Repos) tryValidate() error {
+// todo: move this to Marshal() functions automatically in autogenpb?
+func (repo *Repo) ValidateUTF8() error {
+ if _, err := repo.Marshal(); err == nil {
+ // exit if Marshal() works
+ return nil
+ } else {
+ log.Printf("%s repo.Marshal() failed: %v\n", repo.GetFullPath(), err)
+ }
+ // you only need to do this if Marshal() fails
+ err := bugpb.ValidateProtoUTF8(repo)
+ if err != nil {
+ log.Printf("Protobuf UTF-8 validation failed: %v\n", err)
+ }
+ if err := bugpb.SanitizeProtoUTF8(repo); err != nil {
+ log.Warn("Sanitation failed:", err)
+ return err
+ }
+ return nil
+}
+func (all *Repos) tryValidate() error {
err := bugpb.ValidateProtoUTF8(all)
if err != nil {
log.Printf("Protobuf UTF-8 validation failed: %v\n", err)