-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: 2.4.1
-
Component/s: JavaScript
-
None
-
Environment:AWS m2.2xlarge (AMI: ami-8e27adbe) Production Amazon Linux. RAID10 8 drives on provisioned IOPS data partition. logs partition separate from data
-
Fully Compatible
-
ALL
-
Our .net client stores a long id of 5. Before saving the id however, we convert it to big endian byte[] of 12 in length (to be the same size of mongo object id) for future proofing. This however should not matter as the following is clearly self explanatory.
See "steps to reproduce"
I actually use these JS functions as a work-around which allows me to call:
mongos> BinData(0, hexToBase64(pad((5).toString(16), 24, 0))) BinData(0,"AAAAAAAAAAAAAAAF") //custom JS function definition begins: function pad(n, width, z) { z = z || '0'; n = n + ''; return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; } function btoa(bin) { var tableStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var table = tableStr.split(""); for (var i = 0, j = 0, len = bin.length / 3, base64 = []; i < len; ++i) { var a = bin.charCodeAt(j++), b = bin.charCodeAt(j++), c = bin.charCodeAt(j++); if ((a | b | c) > 255) throw new Error("String contains an invalid character"); base64[base64.length] = table[a >> 2] + table[((a << 4) & 63) | (b >> 4)] + (isNaN(b) ? "=" : table[((b << 2) & 63) | (c >> 6)]) + (isNaN(b + c) ? "=" : table[c & 63]); } return base64.join(""); }; function hexToBase64(str) { return btoa(String.fromCharCode.apply(null, str.replace(/\r|\n/g, "").replace(/([\da-fA-F]{2}) ?/g, "0x$1 ").replace(/ +$/, "").split(" ")) ); }
- is related to
-
SERVER-9583 V8 allows BinData() with no arguments
- Closed
-
SERVER-8819 Add round trip unit jstest framework for 10gen custom types in javascript interpreter
- Closed
-
SERVER-8820 Add jstest to test argument checking of 10gen custom types
- Closed