Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

extendscript-rpc-server

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extendscript-rpc-server - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

52

client.jsx
// taken from http://stackoverflow.com/questions/5515869/string-length-in-bytes-in-javascript
function byteLength(str) {
// returns the byte length of an utf8 string
var s = str.length;
for (var i=str.length-1; i>=0; i--) {
var code = str.charCodeAt(i);
if (code > 0x7f && code <= 0x7ff) s++;
else if (code > 0x7ff && code <= 0xffff) s+=2;
if (code >= 0xDC00 && code <= 0xDFFF) i--; //trail surrogate
// thanks to http://stackoverflow.com/questions/14592364/utf-16-to-utf-8-conversion-in-javascript
function decodeUTF16LE( binaryStr ) {
var cp = [];
for( var i = 0; i < binaryStr.length; i+=2) {
cp.push(
binaryStr.charCodeAt(i) |
( binaryStr.charCodeAt(i+1) << 8 )
);
}
return s;
return String.fromCharCode.apply( String, cp );
}
function encodeUTF16LE( binaryStr ) {
var cp = [];
for( var i = 0; i < binaryStr.length; ++i) {
cp.push(
binaryStr.charCodeAt(i) & 0xFF
);
cp.push(
( (binaryStr.charCodeAt(i) >> 8) & 0xFF )
);
}
return String.fromCharCode.apply( String, cp );
}
function xmlconnection(host) {

@@ -48,6 +63,2 @@ this.sock = new Socket();

if(type == 1) {
this.sock.encoding = 'utf8';
}
data = this.sock.read(length);

@@ -58,8 +69,6 @@ if(!data || !data.length) {

this.sock.encoding = 'binary';
offset += length;
if(type == 1) {
datas.push(new XML(data));
datas.push(new XML(decodeUTF16LE(data)));
} else {

@@ -84,6 +93,6 @@ datas.push({cid: cid, data: data});

if(data.toXMLString) {
var str = data.toXMLString();
data = datas[i] = { cid: 0, type: 1, data: str, length: byteLength(str), charset: 'utf8' };
var str = encodeUTF16LE(data.toXMLString());
data = datas[i] = { cid: 0, type: 1, data: str, length: str.length };
} else {
data = datas[i] = { cid: data.cid || i, type: 2, data: data, length: data.length, charset: 'binary' };
data = datas[i] = { cid: data.cid || i, type: 2, data: data, length: data.length };
}

@@ -115,6 +124,3 @@

this.sock.write(payload);
this.sock.encoding = data.charset || 'binary';
this.sock.write(data.data);
this.sock.encoding = 'binary';
}

@@ -121,0 +127,0 @@

@@ -60,3 +60,3 @@

case 1:
var xmlDATA = et.parse(new Buffer(data.slice(offset3, nextSize + offset3), 'binary').toString('utf8'));
var xmlDATA = et.parse(new Buffer(data.slice(offset3, nextSize + offset3), 'binary').toString('ucs2'));

@@ -90,4 +90,4 @@ var fnc = functionTable[xmlDATA._root.tag];

var xml = etree.write({'xml_declaration': false});
//var len = Buffer.byteLength(xml, 'utf8');
return { cid: cids[index], type: 1, data: xml, length: xml.length };
var edata = new Buffer(xml, 'ucs2');
return { cid: cids[index], type: 1, data: edata, length: edata.length };
}

@@ -122,7 +122,3 @@ });

socket.write(payload2, 'binary');
if(value.type == 1) {
socket.write(value.data, 'utf-8');
} else {
socket.write(value.data, 'binary');
}
socket.write(value.data, 'binary');
});

@@ -129,0 +125,0 @@ });

{
"name": "extendscript-rpc-server",
"version": "1.0.2",
"version": "1.0.3",
"description": "ExtendScript XML / Binary RPC server & client",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc