Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Reject surrogates when decoding UTF-8.

  • Loading branch information...
commit 869071de8f617bcddc304090d97698a54c0618b9 1 parent fe3fbb7
Benjamin Saunders Ralith authored sionescu committed

Showing 1 changed file with 5 additions and 3 deletions. Show diff stats Hide diff stats

  1. +5 3 src/enc-unicode.lisp
8 src/enc-unicode.lisp
@@ -217,9 +217,11 @@ in 2 to 4 bytes."
217 217 ((and (= u1 #xe0) (< u2 #xa0))
218 218 (handle-error 3 overlong-utf8-sequence))
219 219 ((< u1 #xf0) ; 3 octets
220   - (logior (f-ash (f-logand u1 #x0f) 12)
221   - (f-logior (f-ash (f-logand u2 #x3f) 6)
222   - (f-logand u3 #x3f))))
  220 + (let ((start (f-logior (f-ash (f-logand u1 #x0f) 12)
  221 + (f-ash (f-logand u2 #x3f) 6))))
  222 + (if (<= #xd800 start #xdfc0)
  223 + (handle-error 3 character-out-of-range)
  224 + (logior start (f-logand u3 #x3f)))))
223 225 (t ; 4 octets
224 226 (setq u4 (consume-octet))
225 227 (handle-error-if-icb u4 3)

0 comments on commit 869071d

Please sign in to comment.
Something went wrong with that request. Please try again.