aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres/insert_module.go
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2020-06-01 08:34:40 -0400
committerJonathan Amsterdam <jba@google.com>2020-06-01 13:40:36 +0000
commit1d5b18fc5d996d0c8e5596faeaef044bccf69220 (patch)
tree23014f99e2147be609df6e9ab0c40019ed9dd95b /internal/postgres/insert_module.go
parent23f4a4a7593e22d29e4d9b0ad6bf15be77f21ed9 (diff)
downloadgo-x-pkgsite-1d5b18fc5d996d0c8e5596faeaef044bccf69220.tar.xz
internal/postgres: ensure doc HTML is valid UTF-8
We've seen documentation that is not valid UTF-8 (github.com/xuender/oil/math). That results in a DB error when written to a TEXT column. Make the documentation valid before writing to the DB. Change-Id: Ib2ccdd1dfb3b66af9d444b81216f561a8d906d8a Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/757995 Reviewed-by: Julie Qiu <julieqiu@google.com> CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Diffstat (limited to 'internal/postgres/insert_module.go')
-rw-r--r--internal/postgres/insert_module.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/internal/postgres/insert_module.go b/internal/postgres/insert_module.go
index 2fe2c5b9..4c3e33f9 100644
--- a/internal/postgres/insert_module.go
+++ b/internal/postgres/insert_module.go
@@ -274,7 +274,7 @@ func insertPackages(ctx context.Context, db *database.DB, m *internal.Module, is
m.ModulePath,
p.V1Path,
p.IsRedistributable,
- p.DocumentationHTML,
+ makeValidUnicode(p.DocumentationHTML),
pq.Array(licenseTypes),
pq.Array(licensePaths),
p.GOOS,
@@ -465,7 +465,7 @@ func insertDirectories(ctx context.Context, db *database.DB, m *internal.Module,
continue
}
id := pathToID[path]
- docValues = append(docValues, id, doc.GOOS, doc.GOARCH, doc.Synopsis, doc.HTML)
+ docValues = append(docValues, id, doc.GOOS, doc.GOARCH, doc.Synopsis, makeValidUnicode(doc.HTML))
}
docCols := []string{
"path_id",