Skip to content

Commit

Permalink
Manually patch ytdl-core from https://github.com/fent/node-ytdl-core/…
Browse files Browse the repository at this point in the history
  • Loading branch information
benkaiser committed Jul 28, 2024
1 parent 00fcab8 commit a748a00
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2,240 deletions.
58 changes: 45 additions & 13 deletions dist/ytdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3688,7 +3688,7 @@ function Miniget(url, options = {}) {
stream.emit('abort');
stream.destroy(err);
};
let destroyArgs;
let destroyArgs = [];
const streamDestroy = (err) => {
activeRequest.destroy(err);
activeDecodedStream === null || activeDecodedStream === void 0 ? void 0 : activeDecodedStream.unpipe(stream);
Expand Down Expand Up @@ -4865,6 +4865,12 @@ SafeBuffer.allocUnsafeSlow = function (size) {
parser.ns = Object.create(rootNS)
}

// disallow unquoted attribute values if not otherwise configured
// and strict mode is true
if (parser.opt.unquotedAttributeValues === undefined) {
parser.opt.unquotedAttributeValues = !strict;
}

// mostly just for error reporting
parser.trackPosition = parser.opt.position !== false
if (parser.trackPosition) {
Expand Down Expand Up @@ -4958,6 +4964,7 @@ SafeBuffer.allocUnsafeSlow = function (size) {
} catch (ex) {
Stream = function () {}
}
if (!Stream) Stream = function () {}

var streamWraps = sax.EVENTS.filter(function (ev) {
return ev !== 'error' && ev !== 'end'
Expand Down Expand Up @@ -5883,15 +5890,22 @@ SafeBuffer.allocUnsafeSlow = function (size) {
continue

case S.SGML_DECL:
if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
if (parser.sgmlDecl + c === '--') {
parser.state = S.COMMENT
parser.comment = ''
parser.sgmlDecl = ''
continue;
}

if (parser.doctype && parser.doctype !== true && parser.sgmlDecl) {
parser.state = S.DOCTYPE_DTD
parser.doctype += '<!' + parser.sgmlDecl + c
parser.sgmlDecl = ''
} else if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
emitNode(parser, 'onopencdata')
parser.state = S.CDATA
parser.sgmlDecl = ''
parser.cdata = ''
} else if (parser.sgmlDecl + c === '--') {
parser.state = S.COMMENT
parser.comment = ''
parser.sgmlDecl = ''
} else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
parser.state = S.DOCTYPE
if (parser.doctype || parser.sawRoot) {
Expand Down Expand Up @@ -5945,12 +5959,18 @@ SafeBuffer.allocUnsafeSlow = function (size) {
continue

case S.DOCTYPE_DTD:
parser.doctype += c
if (c === ']') {
parser.doctype += c
parser.state = S.DOCTYPE
} else if (c === '<') {
parser.state = S.OPEN_WAKA
parser.startTagPosition = parser.position
} else if (isQuote(c)) {
parser.doctype += c
parser.state = S.DOCTYPE_DTD_QUOTED
parser.q = c
} else {
parser.doctype += c
}
continue

Expand Down Expand Up @@ -5991,6 +6011,8 @@ SafeBuffer.allocUnsafeSlow = function (size) {
// which is a comment of " blah -- bloo "
parser.comment += '--' + c
parser.state = S.COMMENT
} else if (parser.doctype && parser.doctype !== true) {
parser.state = S.DOCTYPE_DTD
} else {
parser.state = S.TEXT
}
Expand Down Expand Up @@ -6158,7 +6180,9 @@ SafeBuffer.allocUnsafeSlow = function (size) {
parser.q = c
parser.state = S.ATTRIB_VALUE_QUOTED
} else {
strictFail(parser, 'Unquoted attribute value')
if (!parser.opt.unquotedAttributeValues) {
error(parser, 'Unquoted attribute value')
}
parser.state = S.ATTRIB_VALUE_UNQUOTED
parser.attribValue = c
}
Expand Down Expand Up @@ -6276,9 +6300,16 @@ SafeBuffer.allocUnsafeSlow = function (size) {
}

if (c === ';') {
parser[buffer] += parseEntity(parser)
parser.entity = ''
parser.state = returnState
var parsedEntity = parseEntity(parser)
if (parser.opt.unparsedEntities && !Object.values(sax.XML_ENTITIES).includes(parsedEntity)) {
parser.entity = ''
parser.state = returnState
parser.write(parsedEntity)
} else {
parser[buffer] += parsedEntity
parser.entity = ''
parser.state = returnState
}
} else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
parser.entity += c
} else {
Expand All @@ -6290,8 +6321,9 @@ SafeBuffer.allocUnsafeSlow = function (size) {

continue

default:
default: /* istanbul ignore next */ {
throw new Error(parser, 'Unknown state: ' + parser.state)
}
}
} // while

Expand Down Expand Up @@ -13704,7 +13736,7 @@ exports.extractFunctions = body => {
}
};
const extractNCode = () => {
let functionName = utils.between(body, `&&(b=a.get("n"))&&(b=`, `(b)`);
let functionName = utils.between(body, 'c=a.get(b))&&(c=', '(c)');
if (functionName.includes('[')) functionName = utils.between(body, `var ${functionName.split('[')[0]}=[`, `]`);
if (functionName && functionName.length) {
const functionStart = `${functionName}=function(a)`;
Expand Down
2 changes: 1 addition & 1 deletion dist/ytdl.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit a748a00

Please sign in to comment.