Handle nul-character in copy/paste (Bug#7934).
* nsselect.m (ns_string_from_pasteboard): Get length of string and use make_string instead of build_string. (ns_string_to_pasteboard_internal): Use initWithBytesNoCopy instead of stringWithUTF8String (Bug#7934).
This commit is contained in:
parent
8907f7b936
commit
497a1925ec
2 changed files with 22 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
|||
2011-01-29 Jan Djärv <jan.h.d@swipnet.se>
|
||||
|
||||
* nsselect.m (ns_string_from_pasteboard): Get length of string
|
||||
and use make_string instead of build_string (Bug#7934).
|
||||
(ns_string_to_pasteboard_internal): Use initWithBytesNoCopy
|
||||
instead of stringWithUTF8String (Bug#7934).
|
||||
|
||||
2011-01-29 Anders Lindgren <andlind@gmail.com> (tiny change)
|
||||
|
||||
* nsfont.m (nsfont_open): Ensure that fonts with inexact
|
||||
|
|
|
@ -153,8 +153,10 @@ Updated by Christian Limpach (chris@nice.ch)
|
|||
CHECK_STRING (str);
|
||||
|
||||
utfStr = SDATA (str);
|
||||
nsStr = [NSString stringWithUTF8String: utfStr];
|
||||
|
||||
nsStr = [[NSString alloc] initWithBytesNoCopy: utfStr
|
||||
length: SBYTES (str)
|
||||
encoding: NSUTF8StringEncoding
|
||||
freeWhenDone: NO];
|
||||
if (gtype == nil)
|
||||
{
|
||||
[pb declareTypes: ns_send_types owner: nil];
|
||||
|
@ -166,6 +168,7 @@ Updated by Christian Limpach (chris@nice.ch)
|
|||
{
|
||||
[pb setString: nsStr forType: gtype];
|
||||
}
|
||||
[nsStr release];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,6 +306,7 @@ Updated by Christian Limpach (chris@nice.ch)
|
|||
{
|
||||
NSString *type, *str;
|
||||
const char *utfStr;
|
||||
int length;
|
||||
|
||||
type = [pb availableTypeFromArray: ns_return_types];
|
||||
if (type == nil)
|
||||
|
@ -344,17 +348,23 @@ Updated by Christian Limpach (chris@nice.ch)
|
|||
options: NSLiteralSearch range: NSMakeRange (0, [mstr length])];
|
||||
|
||||
utfStr = [mstr UTF8String];
|
||||
if (!utfStr)
|
||||
utfStr = [mstr cString];
|
||||
length = [mstr lengthOfBytesUsingEncoding: NSUTF8StringEncoding];
|
||||
|
||||
if (!utfStr)
|
||||
{
|
||||
utfStr = [mstr cString];
|
||||
length = strlen (utfStr);
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
message1 ("ns_string_from_pasteboard: UTF8String failed\n");
|
||||
utfStr = [str lossyCString];
|
||||
length = strlen (utfStr);
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
|
||||
return build_string (utfStr);
|
||||
return make_string (utfStr, length);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue