ninja-dart / pem Goto Github PK
View Code? Open in Web Editor NEWDart library that provides simple and elegant way to decode and encode PEM.
License: BSD 3-Clause "New" or "Revised" License
Dart library that provides simple and elegant way to decode and encode PEM.
License: BSD 3-Clause "New" or "Revised" License
test/bug_test.dart
import 'package:ninja_pem/ninja_pem.dart';
import 'package:test/test.dart';
void main() {
test('CRLF bug', () {
final pemString = "-----BEGIN KEY1-----\r\n"
"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2Np\r\n"
"bmcgZWxpdC4uLkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0LCBjb25zZWN0ZXR1\r\n"
"ciBhZGlwaXNjaW5nIGVsaXQuLi5Mb3JlbSBpcHN1bSBkb2xvciBzaXQgYW1ldCwg\r\n"
"Y29uc2VjdGV0dXIgYWRpcGlzY2luZyBlbGl0Li4uTG9yZW0gaXBzdW0gZG9sb3Ig\r\n"
"c2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4uLkxvcmVtIGlw\r\n"
"c3VtIGRvbG9yIHNpdCBhbWV0LCBjb25zZWN0ZXR1ciBhZGlwaXNjaW5nIGVsaXQu\r\n"
"Li4K\r\n"
"-----END KEY1-----";
final part = PemPart.decodeLabelled(pemString, ['KEY1']);
expect(part.data, isNotEmpty);
});
}
Expected: no error
Actual:
Exception: Invalid data line
package:ninja_pem/src/ninja_pem_base.dart 147:7 _decodeNextPem
package:ninja_pem/src/ninja_pem_base.dart 22:20 new PemPart.decodeLabelled
test\bug_test.dart 16:26 main.<fn>
pem/lib/src/ninja_pem_base.dart
Line 99 in 945bdfd
If moving \r\n
to the first position, the problem will be solved.
static final _newlineRegexp = RegExp(r'(\r\n)|\n|\r');
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.