[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gptel de8d65d9fd: gptel: Trim API keys before sending (#48
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gptel de8d65d9fd: gptel: Trim API keys before sending (#480) |
Date: |
Sun, 24 Nov 2024 21:59:59 -0500 (EST) |
branch: elpa/gptel
commit de8d65d9fd49ba235adb56489f151b91cd6a2343
Author: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
gptel: Trim API keys before sending (#480)
* gptel.el (gptel--get-api-key): Remove trailing newlines from API
keys before sending requests. Leaving in trailing newlines
appears to be a common oversight among users who write custom
functions to extract API keys from their password managers.
---
gptel.el | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/gptel.el b/gptel.el
index afbd133170..7fef4570cb 100644
--- a/gptel.el
+++ b/gptel.el
@@ -751,11 +751,10 @@ and \"apikey\" as USER."
"Get api key from KEY, or from `gptel-api-key'."
(when-let ((key-sym (or key (gptel-backend-key gptel-backend))))
(cl-typecase key-sym
- (function (funcall key-sym))
- (string key-sym)
+ (function (string-trim-right (funcall key-sym) "[\n\r]+"))
+ (string (string-trim-right key-sym "[\n\r]+"))
(symbol (if-let ((val (symbol-value key-sym)))
- (gptel--get-api-key
- (symbol-value key-sym))
+ (gptel--get-api-key val)
(error "`gptel-api-key' is not valid")))
(t (error "`gptel-api-key' is not valid")))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/gptel de8d65d9fd: gptel: Trim API keys before sending (#480),
ELPA Syncer <=