Commit d7877cac authored by Andrew Twyman's avatar Andrew Twyman

Remove stray c_str() to fix handling of embedded nulls

parent 94b98033
...@@ -174,7 +174,7 @@ namespace djinni ...@@ -174,7 +174,7 @@ namespace djinni
static LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) static LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c)
{ {
return {jniEnv, jniStringFromUTF8(jniEnv, c.c_str())}; return {jniEnv, jniStringFromUTF8(jniEnv, c)};
} }
}; };
......
...@@ -76,7 +76,8 @@ bool TestHelpers::check_map_list_record(const MapListRecord & rec) { ...@@ -76,7 +76,8 @@ bool TestHelpers::check_map_list_record(const MapListRecord & rec) {
} }
static const std::string HELLO_WORLD = "Hello World!"; static const std::string HELLO_WORLD = "Hello World!";
static const std::string NON_ASCII = "Non-ASCII / 非 ASCII 字符"; static const std::string NON_ASCII("Non-ASCII /\0 非 ASCII 字符",
sizeof("Non-ASCII /\0 非 ASCII 字符")-1);
void TestHelpers::check_client_interface_ascii(const std::shared_ptr<ClientInterface> & i) { void TestHelpers::check_client_interface_ascii(const std::shared_ptr<ClientInterface> & i) {
ClientReturnedRecord cReturnedRecord = i->get_record(5, HELLO_WORLD, {}); ClientReturnedRecord cReturnedRecord = i->get_record(5, HELLO_WORLD, {});
......
...@@ -5,7 +5,7 @@ import javax.annotation.CheckForNull; ...@@ -5,7 +5,7 @@ import javax.annotation.CheckForNull;
public class ClientInterfaceImpl extends ClientInterface { public class ClientInterfaceImpl extends ClientInterface {
@Override @Override
public ClientReturnedRecord getRecord(long id, String utf8string, String misc) { public ClientReturnedRecord getRecord(long id, String utf8string, String misc) {
if (!utf8string.equals("Non-ASCII / 非 ASCII 字符") && !utf8string.equals("Hello World!")) { if (!utf8string.equals("Non-ASCII /\0 非 ASCII 字符") && !utf8string.equals("Hello World!")) {
throw new RuntimeException("Unexpected string. Check UTF-8?"); throw new RuntimeException("Unexpected string. Check UTF-8?");
} }
return new ClientReturnedRecord(id, utf8string, misc); return new ClientReturnedRecord(id, utf8string, misc);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#import "DBClientReturnedRecord+Private.h" #import "DBClientReturnedRecord+Private.h"
static NSString *DBHelloWorld = @"Hello World!"; static NSString *DBHelloWorld = @"Hello World!";
static NSString *DBNonAscii = @"Non-ASCII / 非 ASCII 字符"; static NSString *DBNonAscii = @"Non-ASCII /\0 非 ASCII 字符";
@implementation DBClientInterfaceImpl @implementation DBClientInterfaceImpl
......
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