master: Correctly signal encoding errors from string-to-octets

stassats via Sbcl-commits <[email protected]>
Newsgroups gmane.lisp.steel-bank.cvs
Message-ID <[email protected]>
The branch "master" has been updated in SBCL:
       via  6fcc8d928b91ee5fbee5ab8453f80aa16e0b3d31 (commit)
      from  ff86fee2c08362a89ff782d500509bdab2280c19 (commit)

- Log -----------------------------------------------------------------
commit 6fcc8d928b91ee5fbee5ab8453f80aa16e0b3d31
Author: Stas Boukarev <[email protected]>
Date:   Mon Aug 24 20:42:27 2026 +0300

    Correctly signal encoding errors from string-to-octets
    
    Fixes lp#2164924
---
 src/code/external-formats/enc-basic.lisp | 2 +-
 tests/utf-8.pure.lisp                    | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/code/external-formats/enc-basic.lisp b/src/code/external-formats/enc-basic.lisp
index 9d7c30641..5874b260b 100644
--- a/src/code/external-formats/enc-basic.lisp
+++ b/src/code/external-formats/enc-basic.lisp
@@ -384,7 +384,7 @@
                                                   ,(if (eql newline :lf)
                                                        :utf-8
                                                        `'(:utf-8 :newline ,newline))
-                                                  replacement string index)))
+                                                  replacement string error-position)))
                                 (flet ((add-byte (b) (vector-push-extend b new-array)))
                                   (dotimes (i (length replacement))
                                     (add-byte (aref replacement i)))
diff --git a/tests/utf-8.pure.lisp b/tests/utf-8.pure.lisp
index 039b9446c..82fb749de 100644
--- a/tests/utf-8.pure.lisp
+++ b/tests/utf-8.pure.lisp
@@ -506,3 +506,11 @@
     (test '(97 128077 98 9989 65039 65039 65039 65039 65039 65039 65039)
           #(97 240 159 145 141 98 226 156 133 239 184 143 239 184 143 239 184 143 239 184 143 239 184 143 239 184 143 239 184 143 0))
     (test '(0 #xd800 1) nil t)))
+
+#+sb-unicode
+(with-test (:name :string-to-octets-encoding-error)
+  (assert
+   (equalp
+    (handler-bind ((sb-int:character-encoding-error (lambda (c) (use-value #\a c))))
+      (string-to-octets (map 'string #'code-char '(233 233 55955 99))))
+    #(195 169 195 169 97 99))))

-----------------------------------------------------------------------


hooks/post-receive
-- 
SBCL
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.