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

uue

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uue - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

2

package.json
{
"name": "uue",
"main": "uue.js",
"version": "1.1.2",
"version": "1.2.0",
"description": "UUE decoder and encoder for Node.js",

@@ -6,0 +6,0 @@ "keywords": ["uue", "uuencode", "uudecode", "uuencoding", "uudecoding"],

@@ -77,2 +77,26 @@ The **UUE** module is able to perform [uuencoding](http://en.wikipedia.org/wiki/Uuencoding) of a file (or Node.js Buffer) to a text message. This module is also able to find uuencoded files in text messages and decode them.

### split(text)
Finds all uuencoded files in the given `text` and splits that text into an array of text blocks and UUE blocks.
Text blocks of the returned array are JavaScript strings.
UUE blocks of the returned array are objects representing the decoded files. Each object has the following properties:
* `name` — the file's name (as it appeared in UUE codes);
* `data` — a Node.js [Buffer](http://nodejs.org/docs/latest/api/buffer.html) containing the file's decoded contents.
* `source` — a JavaScript string containing source UUE codes of the file from (and including) the beginning `'begin'` to (and including) the final `'end'`.
* `type` — always the JavaScript string `'UUE'`. Might help in further processing of the array (i.e. if other types of blocks are going to be decoded from text blocks).
Lines in the given `text` are expected to be separated by `'\n'` (`\x0A`).
Invalid UUE codes are ignored entirely (even if only one line of some UUE code block is wrong, that code block is not decoded and instead is returned as a part of some text block).
The returned array contains blocks in order of their appearance in the given `text`. Unlike `.decodeAllFiles`, even if several uuencoded files have the same `name`, none of them becomes deliberately ignored.
Empty strings (`''`) do not become text blocks of the returned array. (For example, if the given `text` starts with UUE codes, then the first of the returned blocks is a UUE block instead of an empty text block.) This nuance makes this method slightly different from its String's namesake (where `'foo'.split(/(f)/)` returns `['', 'f', 'oo']`) and thus `typeof` has to be used instead of checking whether some element's index is even (or odd).
## Locking files

@@ -79,0 +103,0 @@

@@ -250,3 +250,3 @@ require('array.prototype.findindex');

var potentialUUE = RegExp(
[
[ // detail-capturing version of the RegExp from `.split`
'^begin [0-7]{3} (\\S+?)\n',

@@ -346,6 +346,63 @@ '(',

UUE.prototype.split = function(text){
var processUUE = this;
var potentialUUE = RegExp(
[ // entirely-capturing version of the RegExp from `.decodeAllFiles`
'(',
'^begin [0-7]{3} \\S+?\n',
'(?:[\x20-\x60]+\n)*', // allow garbage after significant characters
'`\n',
'end$',
')'
].join(''),
'gm'
);
return text.split(potentialUUE).map(function(fragment, idx, arr){
/* jshint indent: false */
if( idx % 2 === 0 ){ // simple string fragment's index: 0, 2, 4...
return fragment;
} else { // regex-captured fragment's index: 1, 3, 5...
var decodedFiles = processUUE.decodeAllFiles(fragment);
switch( decodedFiles.length ){
case 0:
// incorrect UUE, append to the previous (always text) fragment
arr[idx-1] += fragment;
return null;
//break;
case 1:
// correct UUE
decodedFiles[0].source = fragment;
decodedFiles[0].type = 'UUE';
return decodedFiles[0];
//break;
default: throw new Error(this.errors.UNEXPECTED_NUMBER_OF_FILES);
}
}
}).filter(function(nextElement){
if( nextElement === '' ) return false;
if( nextElement === null ) return false;
return true;
}).reduce(function(builtArray, nextFragment){
if( typeof nextFragment !== 'string' ){
builtArray.push(nextFragment);
} else { // typeof nextFragment === 'string'
if(
builtArray.length > 0 &&
typeof builtArray[builtArray.length - 1] === 'string'
){ // the array's last element is also a string; appending:
builtArray[builtArray.length - 1] += nextFragment;
} else {
builtArray.push(nextFragment);
}
}
return builtArray;
}, []);
};
UUE.prototype.errors = {
UNKNOWN_SOURCE_TYPE: "The source's type is unknown!"
UNKNOWN_SOURCE_TYPE: "The source's type is unknown!",
UNEXPECTED_NUMBER_OF_FILES: "Unexpected number of files in a fragment!"
};
module.exports = new UUE();
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