New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

js-xdr

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-xdr - npm Package Compare versions

Comparing version 0.0.12 to 1.0.0

8

CHANGELOG.md

@@ -6,9 +6,11 @@ # Changelog

As this project is pre 1.0, breaking changes may happen for minor version
bumps. A breaking change will get clearly notified in this log.
## [v1.0.0](https://github.com/stellar/js-xdr/compare/v0.0.12...v1.0.0)
## [unreleased](https://github.com/stellar/js-xdr/compare/v0.0.11...master)
### Changed
- Strings are now encoded/decoded as utf-8
## [v0.0.12](https://github.com/stellar/js-xdr/compare/v0.0.11...v0.0.12)
### Changed
- bugfix: Hyper.fromString() no longer silently accepts strings with decimal points
- bugfix: UnsignedHyper.fromString() no longer silently accepts strings with decimal points

@@ -43,3 +43,3 @@ "use strict";

io.slice(padding); //consume padding
return result.buffer().toString("ascii");
return result.buffer().toString("utf8");
}

@@ -56,5 +56,5 @@ },

}
var buffer = new Buffer(value, "ascii");
var buffer = new Buffer(value, "utf8");
Int.write(value.length, io);
Int.write(buffer.length, io);
io.writeBufferPadded(buffer);

@@ -65,3 +65,7 @@ }

value: function isValid(value) {
return isString(value) && value.length <= this._maxLength;
if (!isString(value)) {
return false;
}
var buffer = new Buffer(value, "utf8");
return buffer.length <= this._maxLength;
}

@@ -68,0 +72,0 @@ }

{
"name": "js-xdr",
"version": "0.0.12",
"version": "1.0.0",
"description": "Read/write XDR encoded data structures (RFC 4506)",

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

@@ -24,3 +24,3 @@ import { Int } from "./int";

io.slice(padding); //consume padding
return result.buffer().toString('ascii');
return result.buffer().toString('utf8');
}

@@ -38,5 +38,5 @@

}
let buffer = new Buffer(value, 'ascii');
let buffer = new Buffer(value, 'utf8');
Int.write(value.length, io);
Int.write(buffer.length, io);
io.writeBufferPadded(buffer);

@@ -46,6 +46,10 @@ }

isValid(value) {
return isString(value) && value.length <= this._maxLength;
if (!isString(value)) {
return false;
}
let buffer = new Buffer(value, 'utf8');
return buffer.length <= this._maxLength;
}
}
includeIoMixin(String.prototype);
includeIoMixin(String.prototype);
import { Cursor } from "../../src/cursor";
import { cursorToArray } from "../support/io-helpers";
let subject = new XDR.String(2);
let subject = new XDR.String(4);

@@ -11,2 +11,3 @@ describe('String#read', function() {

expect(read([0x00,0x00,0x00,0x01,0x41,0x00,0x00,0x00])).to.eql("A");
expect(read([0x00,0x00,0x00,0x03,0xe4,0xb8,0x89,0x00])).to.eql("三");
expect(read([0x00,0x00,0x00,0x02,0x41,0x41,0x00,0x00])).to.eql("AA");

@@ -16,3 +17,3 @@ });

it("throws a read error when the encoded length is greater than the allowed max", function() {
expect(() => read([0x00,0x00,0x00,0x03])).to.throw(/read error/i);
expect(() => read([0x00,0x00,0x00,0x05,0x41,0x41,0x41,0x41,0x41])).to.throw(/read error/i);
});

@@ -30,2 +31,3 @@

expect(write("")).to.eql([0x00,0x00,0x00,0x00]);
expect(write("三")).to.eql([0x00,0x00,0x00,0x03,0xe4,0xb8,0x89,0x00]);
expect(write("A")).to.eql([0x00,0x00,0x00,0x01,0x41,0x00,0x00,0x00]);

@@ -50,3 +52,3 @@ expect(write("AA")).to.eql([0x00,0x00,0x00,0x02,0x41,0x41,0x00,0x00]);

it('returns false for strings that are too large', function() {
expect(subject.isValid("aaa")).to.be.false;
expect(subject.isValid("aaaaa")).to.be.false;
});

@@ -53,0 +55,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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