summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2015-03-03 15:09:58 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2015-03-05 20:44:18 +0100
commit364cc7e08a5d4b74891362f837ff9c34844c3d35 (patch)
treed371801fcbad38a4016eada51ed52ae70765169b /src
parent826cde866170918fbeeeffc8612d4f4e0a923869 (diff)
downloadandroid-node-v8-364cc7e08a5d4b74891362f837ff9c34844c3d35.tar.gz
android-node-v8-364cc7e08a5d4b74891362f837ff9c34844c3d35.tar.bz2
android-node-v8-364cc7e08a5d4b74891362f837ff9c34844c3d35.zip
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>
Diffstat (limited to 'src')
-rw-r--r--src/node.cc8
-rw-r--r--src/string_bytes.cc7
-rw-r--r--src/string_bytes.h2
-rw-r--r--src/util.cc9
4 files changed, 7 insertions, 19 deletions
diff --git a/src/node.cc b/src/node.cc
index 1bee586033..22c4a9b154 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -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".
diff --git a/src/string_bytes.cc b/src/string_bytes.cc
index c828363da6..4a91f25048 100644
--- a/src/string_bytes.cc
+++ b/src/string_bytes.cc
@@ -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:
diff --git a/src/string_bytes.h b/src/string_bytes.h
index 424d9245aa..2fcfedaa09 100644
--- a/src/string_bytes.h
+++ b/src/string_bytes.h
@@ -10,8 +10,6 @@
namespace node {
-extern int WRITE_UTF8_FLAGS;
-
class StringBytes {
public:
class InlineDecoder {
diff --git a/src/util.cc b/src/util.cc
index 1c57a976e1..1e8d801dba 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -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);