~netlandish/links-dev

links: Add length checker for tag imports. v1 APPLIED

Peter Sanchez: 1
 Add length checker for tag imports.

 1 files changed, 13 insertions(+), 2 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.code.netlandish.com/~netlandish/links-dev/patches/100/mbox | git am -3
Learn more about email & git

[PATCH links] Add length checker for tag imports. Export this patch

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
Applied.

To git@git.code.netlandish.com:~netlandish/links
   513b408..5c1230c  master -> master