src: remove NODE_INVALID_UTF8 environment variable
Introduced in joyent/node v0.10 as a backwards compatibility measure. It's an ugly hack and allowing invalid UTF-8 is not a good idea in the first place, remove it. PR-URL: https://github.com/iojs/io.js/pull/1042 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
parent
826cde8661
commit
364cc7e08a
@ -139,9 +139,6 @@ static uv_async_t dispatch_debug_messages_async;
|
|||||||
|
|
||||||
static Isolate* node_isolate = nullptr;
|
static Isolate* node_isolate = nullptr;
|
||||||
|
|
||||||
int WRITE_UTF8_FLAGS = v8::String::HINT_MANY_WRITES_EXPECTED |
|
|
||||||
v8::String::NO_NULL_TERMINATION;
|
|
||||||
|
|
||||||
class ArrayBufferAllocator : public ArrayBuffer::Allocator {
|
class ArrayBufferAllocator : public ArrayBuffer::Allocator {
|
||||||
public:
|
public:
|
||||||
// Impose an upper limit to avoid out of memory errors that bring down
|
// Impose an upper limit to avoid out of memory errors that bring down
|
||||||
@ -3819,11 +3816,6 @@ static void StartNodeInstance(void* arg) {
|
|||||||
int Start(int argc, char** argv) {
|
int Start(int argc, char** argv) {
|
||||||
PlatformInit();
|
PlatformInit();
|
||||||
|
|
||||||
const char* replace_invalid = secure_getenv("NODE_INVALID_UTF8");
|
|
||||||
|
|
||||||
if (replace_invalid == nullptr)
|
|
||||||
WRITE_UTF8_FLAGS |= String::REPLACE_INVALID_UTF8;
|
|
||||||
|
|
||||||
CHECK_GT(argc, 0);
|
CHECK_GT(argc, 0);
|
||||||
|
|
||||||
// Hack around with the argv pointer. Used for process.title = "blah".
|
// Hack around with the argv pointer. Used for process.title = "blah".
|
||||||
|
@ -287,8 +287,9 @@ size_t StringBytes::Write(Isolate* isolate,
|
|||||||
Local<String> str = val.As<String>();
|
Local<String> str = val.As<String>();
|
||||||
len = len < buflen ? len : buflen;
|
len = len < buflen ? len : buflen;
|
||||||
|
|
||||||
int flags = String::NO_NULL_TERMINATION |
|
int flags = String::HINT_MANY_WRITES_EXPECTED |
|
||||||
String::HINT_MANY_WRITES_EXPECTED;
|
String::NO_NULL_TERMINATION |
|
||||||
|
String::REPLACE_INVALID_UTF8;
|
||||||
|
|
||||||
switch (encoding) {
|
switch (encoding) {
|
||||||
case ASCII:
|
case ASCII:
|
||||||
@ -311,7 +312,7 @@ size_t StringBytes::Write(Isolate* isolate,
|
|||||||
// well?
|
// well?
|
||||||
memcpy(buf, data, len);
|
memcpy(buf, data, len);
|
||||||
else
|
else
|
||||||
len = str->WriteUtf8(buf, buflen, chars_written, WRITE_UTF8_FLAGS);
|
len = str->WriteUtf8(buf, buflen, chars_written, flags);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UCS2:
|
case UCS2:
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
namespace node {
|
namespace node {
|
||||||
|
|
||||||
extern int WRITE_UTF8_FLAGS;
|
|
||||||
|
|
||||||
class StringBytes {
|
class StringBytes {
|
||||||
public:
|
public:
|
||||||
class InlineDecoder {
|
class InlineDecoder {
|
||||||
|
@ -23,12 +23,9 @@ Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Handle<v8::Value> value)
|
|||||||
str = str_st_;
|
str = str_st_;
|
||||||
CHECK_NE(str, NULL);
|
CHECK_NE(str, NULL);
|
||||||
|
|
||||||
int flags = WRITE_UTF8_FLAGS;
|
const int flags =
|
||||||
|
v8::String::NO_NULL_TERMINATION | v8::String::REPLACE_INVALID_UTF8;
|
||||||
length_ = val_->WriteUtf8(str,
|
length_ = val_->WriteUtf8(str, len, 0, flags);
|
||||||
len,
|
|
||||||
0,
|
|
||||||
flags);
|
|
||||||
str[length_] = '\0';
|
str[length_] = '\0';
|
||||||
|
|
||||||
str_ = reinterpret_cast<char*>(str);
|
str_ = reinterpret_cast<char*>(str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user