Convert NUL-containing NSString objects to Lisp strings correctly

This cures the inability to paste text containing NUL from other
applications on macOS, introduced by mistake in 7e3c2b553f
(bug#64697).

* src/nsfns.m ([NSString lispString]): Use make_string instead of
build_string which relies on NUL-termination.
This commit is contained in:
Mattias Engdegård 2023-07-18 15:42:55 +02:00
parent d172cd5985
commit f063f79a49

View file

@ -3829,7 +3829,9 @@ handled fairly well by the NS libraries (displayed with distinct
/* Make a Lisp string from an NSString. */
- (Lisp_Object)lispString
{
return build_string ([self UTF8String]);
// make_string behaves predictably and correctly with UTF-8 input.
return make_string ([self UTF8String],
[self lengthOfBytesUsingEncoding: NSUTF8StringEncoding]);
}
@end