~netlandish/links-dev

links: Fix import error when bookmark title is more than 150 characters v1 APPLIED

Peter Sanchez: 1
 Fix import error when bookmark title is more than 150 characters

 1 files changed, 5 insertions(+), 1 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/99/mbox | git am -3
Learn more about email & git

[PATCH links] Fix import error when bookmark title is more than 150 characters Export this patch

---
One of the few places where we don't use the API for writing and it was
missing a max length check. This is the biggest issue when not using the
single point for storing data, you end up missing checks that already 
exist else where.

 core/import.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/core/import.go b/core/import.go
index c908823..7e6aebb 100644
--- a/core/import.go
+++ b/core/import.go
@@ -283,8 +283,12 @@ func processOrgLinks(obj importObj, baseURLMap map[string]int,
		}
	}

	title := obj.GetTitle()
	if len(title) > 150 {
		title = title[:146] + "..."
	}
	return &models.OrgLink{
		Title:       obj.GetTitle(),
		Title:       title,
		URL:         obj.GetURL(),
		Description: obj.GetDescription(),
		BaseURLID:   sql.NullInt64{Valid: true, Int64: int64(baseID)},
-- 
2.47.2
Applied.

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