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:
Ben Noordhuis 2015-03-03 15:09:58 +01:00
Родитель 826cde8661
Коммит 364cc7e08a
4 изменённых файлов: 7 добавлений и 19 удалений

Просмотреть файл

@ -139,9 +139,6 @@ static uv_async_t dispatch_debug_messages_async;
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 {
public:
// 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) {
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);
// 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>();
len = len < buflen ? len : buflen;
int flags = String::NO_NULL_TERMINATION |
String::HINT_MANY_WRITES_EXPECTED;
int flags = String::HINT_MANY_WRITES_EXPECTED |
String::NO_NULL_TERMINATION |
String::REPLACE_INVALID_UTF8;
switch (encoding) {
case ASCII:
@ -311,7 +312,7 @@ size_t StringBytes::Write(Isolate* isolate,
// well?
memcpy(buf, data, len);
else
len = str->WriteUtf8(buf, buflen, chars_written, WRITE_UTF8_FLAGS);
len = str->WriteUtf8(buf, buflen, chars_written, flags);
break;
case UCS2:

Просмотреть файл

@ -10,8 +10,6 @@
namespace node {
extern int WRITE_UTF8_FLAGS;
class StringBytes {
public:
class InlineDecoder {

Просмотреть файл

@ -23,12 +23,9 @@ Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Handle<v8::Value> value)
str = str_st_;
CHECK_NE(str, NULL);
int flags = WRITE_UTF8_FLAGS;
length_ = val_->WriteUtf8(str,
len,
0,
flags);
const int flags =
v8::String::NO_NULL_TERMINATION | v8::String::REPLACE_INVALID_UTF8;
length_ = val_->WriteUtf8(str, len, 0, flags);
str[length_] = '\0';
str_ = reinterpret_cast<char*>(str);