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

ytdl-core

Package Overview
Dependencies
Maintainers
1
Versions
186
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ytdl-core - npm Package Compare versions

Comparing version 4.11.0 to 4.11.1

2

lib/info.js

@@ -268,3 +268,3 @@ const querystring = require('querystring');

}
return parseJSON(source, varName, utils.cutAfterJSON(`${prependJSON}${jsonStr}`));
return parseJSON(source, varName, utils.cutAfterJS(`${prependJSON}${jsonStr}`));
};

@@ -271,0 +271,0 @@

@@ -42,3 +42,3 @@ const querystring = require('querystring');

const subBody = body.slice(ndx + functionStart.length - 1);
return `var ${functionName}=${utils.cutAfterJSON(subBody)}`;
return `var ${functionName}=${utils.cutAfterJS(subBody)}`;
};

@@ -52,3 +52,3 @@ const extractDecipher = () => {

const subBody = body.slice(ndx + functionStart.length);
let functionBody = `var ${functionStart}${utils.cutAfterJSON(subBody)}`;
let functionBody = `var ${functionStart}${utils.cutAfterJS(subBody)}`;
functionBody = `${extractManipulations(functionBody)};${functionBody};${functionName}(sig);`;

@@ -67,3 +67,3 @@ functions.push(functionBody);

const subBody = body.slice(ndx + functionStart.length);
const functionBody = `var ${functionStart}${utils.cutAfterJSON(subBody)};${functionName}(ncode);`;
const functionBody = `var ${functionStart}${utils.cutAfterJS(subBody)};${functionName}(ncode);`;
functions.push(functionBody);

@@ -70,0 +70,0 @@ }

@@ -51,5 +51,19 @@ const miniget = require('miniget');

/**
* Escape sequences for cutAfterJS
* @param {string} start the character string the escape sequence
* @param {string} end the character string to stop the escape seequence
* @param {undefined|Regex} startPrefix a regex to check against the preceding 10 characters
*/
const ESCAPING_SEQUENZES = [
// Strings
{ start: '"', end: '"' },
{ start: "'", end: "'" },
{ start: '`', end: '`' },
// RegeEx
{ start: '/', end: '/', startPrefix: /(^|[[{:;,])\s+$/ },
];
/**
* Match begin and end braces of input JSON, return only json
* Match begin and end braces of input JS, return only JS
*

@@ -59,3 +73,4 @@ * @param {string} mixedJson

*/
exports.cutAfterJSON = mixedJson => {
exports.cutAfterJS = mixedJson => {
// Define the general open and closing tag
let open, close;

@@ -74,4 +89,4 @@ if (mixedJson[0] === '[') {

// States if the loop is currently in a string
let isString = false;
// States if the loop is currently inside an escaped js object
let isEscapedObject = null;

@@ -85,7 +100,22 @@ // States if the current character is treated as escaped or not

let i;
// Go through all characters from the start
for (i = 0; i < mixedJson.length; i++) {
// Toggle the isString boolean when leaving/entering string
if (mixedJson[i] === '"' && !isEscaped) {
isString = !isString;
// End of current escaped object
if (!isEscaped && isEscapedObject !== null && mixedJson[i] === isEscapedObject.end) {
isEscapedObject = null;
continue;
// Might be the start of a new escaped object
} else if (!isEscaped && isEscapedObject === null) {
for (const escaped of ESCAPING_SEQUENZES) {
if (mixedJson[i] !== escaped.start) continue;
// Test startPrefix against last 10 characters
if (!escaped.startPrefix || mixedJson.substring(i - 10, i).match(escaped.startPrefix)) {
isEscapedObject = escaped;
break;
}
}
// Continue if we found a new escaped object
if (isEscapedObject !== null) {
continue;
}
}

@@ -97,3 +127,3 @@

if (isString) continue;
if (isEscapedObject !== null) continue;

@@ -109,3 +139,3 @@ if (mixedJson[i] === open) {

// Return the cut JSON
return mixedJson.substr(0, i + 1);
return mixedJson.substring(0, i + 1);
}

@@ -112,0 +142,0 @@ }

@@ -9,3 +9,3 @@ {

],
"version": "4.11.0",
"version": "4.11.1",
"repository": {

@@ -12,0 +12,0 @@ "type": "git",

@@ -39,3 +39,3 @@ # node-ytdl-core

* `dlChunkSize` - When the chosen format is video only or audio only, the download is separated into multiple chunks to avoid throttling. This option specifies the size of each chunk in bytes. Setting it to 0 disables chunking. Defaults to 10MB.
* `IPv6Block` - IPv6 block to rotate through, an alternative to using a proxy. [Read more](#How-does-using-an-IPv6-block-help?). Defaults to `undefined`.
* `IPv6Block` - IPv6 block to rotate through, an alternative to using a proxy. [Read more](#how-does-using-an-ipv6-block-help). Defaults to `undefined`.

@@ -42,0 +42,0 @@ #### Event: info

@@ -131,5 +131,3 @@ declare module 'ytdl-core' {

isCrawlable: boolean;
thumbnail: {
thumbnails: thumbnail[];
};
thumbnails: thumbnail[];
averageRating: number;

@@ -136,0 +134,0 @@ allowRatings: boolean;

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