Commit 497a1925 authored by Jan Djärv's avatar Jan Djärv
Browse files

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).
parent 8907f7b9
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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment