Received: from mail.netlandish.com (mail.netlandish.com [174.136.98.166]) by code.netlandish.com (Postfix) with ESMTP id 2DA69A4 for <~netlandish/links-dev@lists.code.netlandish.com>; Fri, 21 Feb 2025 23:26:35 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.128.181; helo=mail-yw1-f181.google.com; envelope-from=peter@netlandish.com; receiver= Authentication-Results: mail.netlandish.com; dkim=pass (1024-bit key; unprotected) header.d=netlandish.com header.i=@netlandish.com header.b=cEI69IAc Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) by mail.netlandish.com (Postfix) with ESMTP id 24FA11D6432 for <~netlandish/links-dev@lists.code.netlandish.com>; Fri, 21 Feb 2025 23:34:36 +0000 (UTC) Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-6fbaa0582a6so26395547b3.1 for <~netlandish/links-dev@lists.code.netlandish.com>; Fri, 21 Feb 2025 15:34:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netlandish.com; s=google; t=1740180875; x=1740785675; darn=lists.code.netlandish.com; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=6icNm5d87uCGq3qdVDQ4/fVaAmYWGwrSnsCNfoalnPw=; b=cEI69IAcutlSCC2iKLUXuWKkMkuqJQTI/sIr//txT3zs2/5tHVPSdiq3g3BnG2feZP 26NwTQCrnODRIyiOd1MfG3AA7uvVuXHQEeK/qgq8TNst5/8k9mJNqQV+IWQHPYLQdTqJ KQa2jJUKazbABInhEBK7DoZxc7YyJaqYWjYTI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740180875; x=1740785675; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6icNm5d87uCGq3qdVDQ4/fVaAmYWGwrSnsCNfoalnPw=; b=tzYT+GCVnLs+/ASk73j7ITt0Rd94i/Pj99Yh77GpJ/k+SbQkUHCDTwzFrhJfrLk+Vj 2kps2imxxNnTDTD+3gcbTWu/DutytRUfJYuLEGpdu6zYEfOCOHbTDqhzijJAjd622fnK VbiWrp+2p1/+dYjtqCZWNd3vM+U9OMnRCYRffy47VJ40lspUF+dR1BM4aCnZx290HhJ1 xLYlisfhI+DAyCtYVmrKuHN14pIRmsStISvL4AaYN/BMCT14BZs9EkvS4q6sFXvZGoUX 6VwFkBvbeU07jOCUDAWiVTTFE8FrN+3LOG/yx57TRpCImrVkGseIig/vVIRyWzA/ep8J mq5Q== X-Gm-Message-State: AOJu0YwKBGDQ8JhImTsWljy67jL270VtDFT38/a9odR7XjvuWStz6P3v dpLyb7cq1r7Gz4k+Mdui5xw3H5wCqHz/ZMd4JkVQVqKyScVLHOq2b1+cikAxTlH/UiD4BCCIDdc vCng= X-Gm-Gg: ASbGncuK3wJ2Vn+X2kcmQsC6oZw0gX/KIVTWz6VDSlFzEcWElLasuUR8sZOADrNIahb CZXiIZKmUZbm28SGfmPNRhSw5+wi7XodkydfvbsnOtXY9mKshw05ML7paQ0ihuLXOfBbRrCe5f1 5faez0SWjDPBInc8aEaEZWYPV3AW1w/8RXWFpqchfbWhXM2XyfZgqtQwsydcOCFVCu/gqbyiy/b fUz0inoetXSdiUkYTiOewvTPDquAPiV8orV1TJY71lLka+OYzi+lra6IL1ClUrga+vxjCXL9ele F2Og/55X2Gw5mghcO1ZUADCYAA== X-Google-Smtp-Source: AGHT+IE39L0HhEZWmjdLIdAPgeK2SNgpqPGAXjA9kj7MmXw6HEG4K8Q+QRIyaiWys0/GU9oQPH14zw== X-Received: by 2002:a05:690c:630d:b0:6f9:c487:2c26 with SMTP id 00721157ae682-6fbb79cbbe8mr93370497b3.15.1740180875521; Fri, 21 Feb 2025 15:34:35 -0800 (PST) Received: from localhost ([2803:2d60:1118:5ee:bd8:a3af:9c0f:81c0]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6fba0844b54sm19155117b3.23.2025.02.21.15.34.34 for <~netlandish/links-dev@lists.code.netlandish.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2025 15:34:35 -0800 (PST) From: Peter Sanchez To: ~netlandish/links-dev@lists.code.netlandish.com Subject: [PATCH links] Fix import error when bookmark title is more than 150 characters Date: Fri, 21 Feb 2025 17:33:17 -0600 Message-ID: <20250221233432.30703-1-peter@netlandish.com> X-Mailer: git-send-email 2.47.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit --- 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