Subject: [PATCH links] Add length checker for tag imports.

From: Peter Sanchez <[email-masked]>
Date: Tue, 25 Feb 2025 07:05:00 -0600

Changelog-added: additional import sanity checking to avoid db layer
  errors (ie, max length exceeded).
---
Follow up to a previous commit (513b4084ea) to avoid possible import
errors when tags violate max length

 core/import.go | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/core/import.go b/core/import.go
index 7e6aebb..59e2437 100644
--- a/core/import.go
+++ b/core/import.go
@@ -107,7 +107,18 @@ func (p pinBoardObj) IsUnread() bool {
 }
 
 func (p pinBoardObj) GetTags() []string {
-	return strings.Split(strings.TrimSpace(p.Tags), " ")
+	return trimTags(strings.Split(strings.TrimSpace(p.Tags), " "))
+}
+
+func trimTags(tags []string) []string {
+	var ret []string
+	for _, t := range tags {
+		if len(t) > 50 {
+			t = t[:50]
+		}
+		ret = append(ret, t)
+	}
+	return ret
 }
 
 // Especific html object representation, used by Safari and Chrome
@@ -161,7 +172,7 @@ func (h htmlObj) IsUnread() bool {
 }
 
 func (h htmlObj) GetTags() []string {
-	return strings.Split(strings.TrimSpace(h.Tags), ",")
+	return trimTags(strings.Split(strings.TrimSpace(h.Tags), ","))
 }
 
 // This adapter struct is used to wrap a slice [n:m]
-- 
2.47.2