mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
ECMAScript: If accessKey is a surrogate, throw an error when reading it.
Surrogates are now treated the same way as out-of-range characters like U+110000; if a link has such an access key, then the ECMAScript accessKey property cannot be read. It seems currently impossible to set such an access key though, because accesskey_string_to_unicode() doesn't support multibyte characters yet.
This commit is contained in:
parent
55212827c7
commit
8850d85998
@ -231,7 +231,9 @@ void shrink_format_cache(int);
|
||||
extern struct module document_module;
|
||||
|
||||
/* FIXME: support for entities and all Unicode characters.
|
||||
* For now, we only support simple printable character. */
|
||||
* (Unpaired surrogates should be rejected, so that the ECMAScript
|
||||
* interface can convert the access key to UTF-16.)
|
||||
* For now, we only support simple printable character. */
|
||||
#define accesskey_string_to_unicode(s) (((s)[0] && !(s)[1] && isprint((s)[0])) ? (s)[0] : 0)
|
||||
|
||||
#endif
|
||||
|
@ -107,9 +107,11 @@ append_unicode_to_SEE_string(struct SEE_interpreter *interp,
|
||||
struct SEE_string *str,
|
||||
unicode_val_T u)
|
||||
{
|
||||
if (u <= 0xFFFF) {
|
||||
/* TODO: Should this reject code points in the
|
||||
* surrogate range? */
|
||||
/* This is supposed to make a string from which
|
||||
* SEE_string_to_unicode() can get the original @u back.
|
||||
* If @u is a surrogate, then that is not possible, so
|
||||
* throw an error instead. */
|
||||
if (u <= 0xFFFF && !is_utf16_surrogate(u)) {
|
||||
SEE_string_addch(str, u);
|
||||
} else if (needs_utf16_surrogates(u)) {
|
||||
SEE_string_addch(str, get_utf16_high_surrogate(u));
|
||||
|
@ -989,13 +989,16 @@ unicode_to_jsstring(JSContext *ctx, unicode_val_T u)
|
||||
{
|
||||
jschar buf[2];
|
||||
|
||||
/* If JS_NewUCStringCopyN hits a null character, it truncates
|
||||
/* This is supposed to make a string from which
|
||||
* jsval_to_accesskey() can get the original @u back.
|
||||
* If @u is a surrogate, then that is not possible, so
|
||||
* return NULL to indicate an error instead.
|
||||
*
|
||||
* If JS_NewUCStringCopyN hits a null character, it truncates
|
||||
* the string there and pads it with more nulls. However,
|
||||
* that is not a problem here, because if there is a null
|
||||
* character in buf[], then it must be the only character. */
|
||||
if (u <= 0xFFFF) {
|
||||
/* TODO: Should this reject code points in the
|
||||
* surrogate range? */
|
||||
if (u <= 0xFFFF && !is_utf16_surrogate(u)) {
|
||||
buf[0] = u;
|
||||
return JS_NewUCStringCopyN(ctx, buf, 1);
|
||||
} else if (needs_utf16_surrogates(u)) {
|
||||
|
Loading…
Reference in New Issue
Block a user