aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1998-11-11 03:36:15 +0000
committerKenichi Handa1998-11-11 03:36:15 +0000
commit9b4d1fe69d4e22951849b8b5dc80ed3d2f3c15f1 (patch)
treedaea20c827b0e7ab8e36631320fe0c8fa10966ff
parent861bf815f33fa593283aecb9eda31cdecfa9207a (diff)
downloademacs-9b4d1fe69d4e22951849b8b5dc80ed3d2f3c15f1.tar.gz
emacs-9b4d1fe69d4e22951849b8b5dc80ed3d2f3c15f1.zip
(str_cmpchar_id): Check the byte sequence for
composition more rigidly. (Fcompose_string): Allow DEL to be composed. Signal error if STR contains an invalid multibyte sequence.
-rw-r--r--src/charset.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/charset.c b/src/charset.c
index 41b90189f1d..a96d39b4a56 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1417,7 +1417,12 @@ str_cmpchar_id (str, len)
1417 p = str + 1; 1417 p = str + 1;
1418 while (p < endp) 1418 while (p < endp)
1419 { 1419 {
1420 if (embedded_rule) p++; 1420 if (embedded_rule)
1421 {
1422 p++;
1423 if (p >= endp)
1424 return -1;
1425 }
1421 /* No need of checking if *P is 0xA0 because 1426 /* No need of checking if *P is 0xA0 because
1422 BYTES_BY_CHAR_HEAD (0x80) surely returns 2. */ 1427 BYTES_BY_CHAR_HEAD (0x80) surely returns 2. */
1423 p += BYTES_BY_CHAR_HEAD (*p - 0x20); 1428 p += BYTES_BY_CHAR_HEAD (*p - 0x20);
@@ -1719,7 +1724,7 @@ DEFUN ("compose-string", Fcompose_string, Scompose_string,
1719 i = 1; 1724 i = 1;
1720 while (p < pend) 1725 while (p < pend)
1721 { 1726 {
1722 if (*p < 0x20 || *p == 127) /* control code */ 1727 if (*p < 0x20) /* control code */
1723 error ("Invalid component character: %d", *p); 1728 error ("Invalid component character: %d", *p);
1724 else if (*p < 0x80) /* ASCII */ 1729 else if (*p < 0x80) /* ASCII */
1725 { 1730 {
@@ -1740,6 +1745,8 @@ DEFUN ("compose-string", Fcompose_string, Scompose_string,
1740 error ("Can't compose a rule-based composition character"); 1745 error ("Can't compose a rule-based composition character");
1741 ptemp = p; 1746 ptemp = p;
1742 while (! CHAR_HEAD_P (*p)) p++; 1747 while (! CHAR_HEAD_P (*p)) p++;
1748 if (str_cmpchar_id (ptemp - 1, p - ptemp + 1) < 0)
1749 error ("Can't compose an invalid composition character");
1743 if (i + (p - ptemp) >= MAX_LENGTH_OF_MULTI_BYTE_FORM) 1750 if (i + (p - ptemp) >= MAX_LENGTH_OF_MULTI_BYTE_FORM)
1744 error ("Too long string to be composed: %s", XSTRING (str)->data); 1751 error ("Too long string to be composed: %s", XSTRING (str)->data);
1745 bcopy (ptemp, buf + i, p - ptemp); 1752 bcopy (ptemp, buf + i, p - ptemp);
@@ -1749,7 +1756,10 @@ DEFUN ("compose-string", Fcompose_string, Scompose_string,
1749 { 1756 {
1750 /* Add 0x20 to the base leading-code, keep the remaining 1757 /* Add 0x20 to the base leading-code, keep the remaining
1751 bytes unchanged. */ 1758 bytes unchanged. */
1752 len = BYTES_BY_CHAR_HEAD (*p); 1759 int c = STRING_CHAR_AND_CHAR_LENGTH (p, pend - p, len);
1760
1761 if (len <= 1 || ! CHAR_VALID_P (c, 0))
1762 error ("Can't compose an invalid character");
1753 if (i + len >= MAX_LENGTH_OF_MULTI_BYTE_FORM) 1763 if (i + len >= MAX_LENGTH_OF_MULTI_BYTE_FORM)
1754 error ("Too long string to be composed: %s", XSTRING (str)->data); 1764 error ("Too long string to be composed: %s", XSTRING (str)->data);
1755 bcopy (p, buf + i, len); 1765 bcopy (p, buf + i, len);