summaryrefslogtreecommitdiff
path: root/src/mongo/scripting/v8_db.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/scripting/v8_db.cpp')
-rw-r--r--src/mongo/scripting/v8_db.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/mongo/scripting/v8_db.cpp b/src/mongo/scripting/v8_db.cpp
index ea6cfe33591..1572ac52a3f 100644
--- a/src/mongo/scripting/v8_db.cpp
+++ b/src/mongo/scripting/v8_db.cpp
@@ -743,8 +743,9 @@ namespace mongo {
// uassert if invalid base64 string
string tmpBase64 = base64::decode(*utf);
// length property stores the decoded length
- it->ForceSet(scope->v8StringData("len"), v8::Number::New(tmpBase64.length()));
- it->ForceSet(scope->v8StringData("type"), type);
+ it->ForceSet(scope->v8StringData("len"), v8::Number::New(tmpBase64.length()),
+ v8::ReadOnly);
+ it->ForceSet(scope->v8StringData("type"), type, v8::ReadOnly);
it->SetInternalField(0, args[1]);
}
else if (args.Length() != 0) {
@@ -775,15 +776,14 @@ namespace mongo {
v8::Handle<v8::Value> binDataToHex(V8Scope* scope, const v8::Arguments& args) {
v8::Handle<v8::Object> it = args.This();
verify(scope->BinDataFT()->HasInstance(it));
- int len = v8::Handle<v8::Number>::Cast(it->Get(v8::String::New("len")))->Int32Value();
verify(it->InternalFieldCount() == 1);
string data = base64::decode(toSTLString(it->GetInternalField(0)));
stringstream ss;
ss.setf (ios_base::hex, ios_base::basefield);
ss.fill ('0');
ss.setf (ios_base::right, ios_base::adjustfield);
- for(int i = 0; i < len; i++) {
- unsigned v = (unsigned char) data[i];
+ for(std::string::iterator it = data.begin(); it != data.end(); ++it) {
+ unsigned v = (unsigned char) *it;
ss << setw(2) << v;
}
return v8::String::New(ss.str().c_str());