From c77172469fa99e425600cda08b3f9e5644ff51c2 Mon Sep 17 00:00:00 2001 From: Marielle Volz Date: Wed, 21 Aug 2024 10:00:34 +0100 Subject: [PATCH] Fix prototype function pollution Fixes #53 per MadsAppvice --- lib/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 74e2c9c..d960619 100644 --- a/lib/index.js +++ b/lib/index.js @@ -23,16 +23,16 @@ exports.parseAll = function ( chtml ) { const arr = keys.map( ( key ) => exports.metadataFunctions[ key ]( chtml ) ); let result; // Result in for loop over results - let key; // Key corrsponding to location of result + let key; // Key corresponding to location of result return BBPromise.all( arr.map( ( x ) => x.reflect() ) ) .then( ( results ) => { - for ( const r in results ) { + Object.keys( results ).forEach( function ( r ) { result = results[ r ]; key = keys[ r ]; if ( result && result.isFulfilled() && result.value() ) { meta[ key ] = result.value(); } - } + } ); if ( Object.keys( meta ).length === 0 ) { throw new Error( 'No metadata found in page' ); }