summaryrefslogtreecommitdiff
path: root/test/src/buffer-tests.el
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-04-20 22:26:30 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-04-20 22:31:11 -0700
commitc88a3be8087ad0165415aa87c01f868a7433cb21 (patch)
tree5bba8004c1846653aa514416d31c6b47034df740 /test/src/buffer-tests.el
parent856d9378a49ec9ec1af2ea74fb9309fe4c39cd1d (diff)
downloademacs-c88a3be8087ad0165415aa87c01f868a7433cb21.tar.gz
Fix string-to-multibyte overlong sequence bug
* src/character.h (MULTIBYTE_LENGTH, MULTIBYTE_LENGTH_NO_CHECK): Remove, replacing with ... (multibyte_length): ... this new function. All callers changed. The new function rejects overlong multibyte forms. * test/src/buffer-tests.el (buffer-multibyte-overlong-sequences): New test.
Diffstat (limited to 'test/src/buffer-tests.el')
-rw-r--r--test/src/buffer-tests.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el
index 1c356698f66..6e87cb94897 100644
--- a/test/src/buffer-tests.el
+++ b/test/src/buffer-tests.el
@@ -1313,4 +1313,18 @@ with parameters from the *Messages* buffer modification."
(ovshould nonempty-eob-end 4 5)
(ovshould empty-eob 5 5)))))
+(ert-deftest buffer-multibyte-overlong-sequences ()
+ (dolist (uni '("\xE0\x80\x80"
+ "\xF0\x80\x80\x80"
+ "\xF8\x8F\xBF\xBF\x80"))
+ (let ((multi (string-to-multibyte uni)))
+ (should
+ (string-equal
+ multi
+ (with-temp-buffer
+ (set-buffer-multibyte nil)
+ (insert uni)
+ (set-buffer-multibyte t)
+ (buffer-string)))))))
+
;;; buffer-tests.el ends here