handlebars-source 4.7.8 → 4.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/handlebars.js +480 -155
  3. data/handlebars.runtime.js +149 -93
  4. metadata +3 -3
@@ -1,7 +1,7 @@
1
1
  /**!
2
2
 
3
3
  @license
4
- handlebars v4.7.8
4
+ handlebars v4.7.10
5
5
 
6
6
  Copyright (C) 2011-2019 by Yehuda Katz
7
7
 
@@ -95,7 +95,7 @@ return /******/ (function(modules) { // webpackBootstrap
95
95
  // Each of these augment the Handlebars object. No need to setup here.
96
96
  // (This is done to easily share code between commonjs and browse envs)
97
97
 
98
- var _handlebarsSafeString = __webpack_require__(76);
98
+ var _handlebarsSafeString = __webpack_require__(75);
99
99
 
100
100
  var _handlebarsSafeString2 = _interopRequireDefault(_handlebarsSafeString);
101
101
 
@@ -107,11 +107,11 @@ return /******/ (function(modules) { // webpackBootstrap
107
107
 
108
108
  var Utils = _interopRequireWildcard(_handlebarsUtils);
109
109
 
110
- var _handlebarsRuntime = __webpack_require__(77);
110
+ var _handlebarsRuntime = __webpack_require__(76);
111
111
 
112
112
  var runtime = _interopRequireWildcard(_handlebarsRuntime);
113
113
 
114
- var _handlebarsNoConflict = __webpack_require__(82);
114
+ var _handlebarsNoConflict = __webpack_require__(81);
115
115
 
116
116
  var _handlebarsNoConflict2 = _interopRequireDefault(_handlebarsNoConflict);
117
117
 
@@ -209,7 +209,7 @@ return /******/ (function(modules) { // webpackBootstrap
209
209
 
210
210
  var _internalProtoAccess = __webpack_require__(72);
211
211
 
212
- var VERSION = '4.7.8';
212
+ var VERSION = '4.7.10';
213
213
  exports.VERSION = VERSION;
214
214
  var COMPILER_REVISION = 8;
215
215
  exports.COMPILER_REVISION = COMPILER_REVISION;
@@ -383,8 +383,9 @@ return /******/ (function(modules) { // webpackBootstrap
383
383
 
384
384
  function escapeExpression(string) {
385
385
  if (typeof string !== 'string') {
386
- // don't escape SafeStrings, since they're already safe
387
- if (string && string.toHTML) {
386
+ // don't escape SafeStrings, since they're already safe. Other values with a
387
+ // "toHTML" key, e.g. from JSON context data, are escaped like any object.
388
+ if (string && typeof string.toHTML === 'function') {
388
389
  return string.toHTML();
389
390
  } else if (string == null) {
390
391
  return '';
@@ -447,11 +448,15 @@ return /******/ (function(modules) { // webpackBootstrap
447
448
  column = undefined,
448
449
  endColumn = undefined;
449
450
 
450
- if (loc) {
451
+ // Hand-built ASTs may carry a partial loc; never let the location
452
+ // bookkeeping mask the actual error message.
453
+ if (loc && loc.start) {
451
454
  line = loc.start.line;
452
- endLineNumber = loc.end.line;
453
455
  column = loc.start.column;
454
- endColumn = loc.end.column;
456
+ if (loc.end) {
457
+ endLineNumber = loc.end.line;
458
+ endColumn = loc.end.column;
459
+ }
455
460
 
456
461
  message += ' - ' + line + ':' + column;
457
462
  }
@@ -586,7 +591,8 @@ return /******/ (function(modules) { // webpackBootstrap
586
591
  if (instance.helpers[helperName]) {
587
592
  instance.hooks[helperName] = instance.helpers[helperName];
588
593
  if (!keepHelper) {
589
- delete instance.helpers[helperName];
594
+ // Using delete is slow
595
+ instance.helpers[helperName] = undefined;
590
596
  }
591
597
  }
592
598
  }
@@ -658,6 +664,26 @@ return /******/ (function(modules) { // webpackBootstrap
658
664
 
659
665
  var _exception2 = _interopRequireDefault(_exception);
660
666
 
667
+ /**
668
+ * Close an unfinished iterator after the block body threw, like for...of does,
669
+ * so that generators can run their cleanup code.
670
+ *
671
+ * Errors thrown while closing, including by a `return` getter, are ignored:
672
+ * the block's error is the cause and is the one the caller must see.
673
+ *
674
+ * @param {Iterator} iterator the iterator that was being consumed
675
+ */
676
+ function closeIterator(iterator) {
677
+ try {
678
+ var _close = iterator['return'];
679
+ if (_utils.isFunction(_close)) {
680
+ _close.call(iterator);
681
+ }
682
+ } catch (closeError) {
683
+ // NOP
684
+ }
685
+ }
686
+
661
687
  exports['default'] = function (instance) {
662
688
  instance.registerHelper('each', function (context, options) {
663
689
  if (!options) {
@@ -683,7 +709,7 @@ return /******/ (function(modules) { // webpackBootstrap
683
709
  data = _utils.createFrame(options.data);
684
710
  }
685
711
 
686
- function execIteration(field, index, last) {
712
+ function execIteration(field, index, last, value) {
687
713
  if (data) {
688
714
  data.key = field;
689
715
  data.index = index;
@@ -695,9 +721,9 @@ return /******/ (function(modules) { // webpackBootstrap
695
721
  }
696
722
  }
697
723
 
698
- ret = ret + fn(context[field], {
724
+ ret = ret + fn(value, {
699
725
  data: data,
700
- blockParams: _utils.blockParams([context[field], field], [contextPath + field, null])
726
+ blockParams: _utils.blockParams([value, field], [contextPath + field, null])
701
727
  });
702
728
  }
703
729
 
@@ -705,18 +731,24 @@ return /******/ (function(modules) { // webpackBootstrap
705
731
  if (_utils.isArray(context)) {
706
732
  for (var j = context.length; i < j; i++) {
707
733
  if (i in context) {
708
- execIteration(i, i, i === context.length - 1);
734
+ execIteration(i, i, i === context.length - 1, context[i]);
709
735
  }
710
736
  }
711
737
  } else if (typeof _Symbol === 'function' && context[_Symbol$iterator]) {
712
- var newContext = [];
713
738
  var iterator = _getIterator(context);
714
- for (var it = iterator.next(); !it.done; it = iterator.next()) {
715
- newContext.push(it.value);
716
- }
717
- context = newContext;
718
- for (var j = context.length; i < j; i++) {
719
- execIteration(i, i, i === context.length - 1);
739
+ var current = iterator.next();
740
+ while (!current.done) {
741
+ var next = iterator.next();
742
+ try {
743
+ execIteration(i, i, next.done, current.value);
744
+ } catch (e) {
745
+ if (!next.done) {
746
+ closeIterator(iterator);
747
+ }
748
+ throw e;
749
+ }
750
+ current = next;
751
+ i++;
720
752
  }
721
753
  } else {
722
754
  (function () {
@@ -727,13 +759,13 @@ return /******/ (function(modules) { // webpackBootstrap
727
759
  // the last iteration without have to scan the object twice and create
728
760
  // an itermediate keys array.
729
761
  if (priorKey !== undefined) {
730
- execIteration(priorKey, i - 1);
762
+ execIteration(priorKey, i - 1, false, context[priorKey]);
731
763
  }
732
764
  priorKey = key;
733
765
  i++;
734
766
  });
735
767
  if (priorKey !== undefined) {
736
- execIteration(priorKey, i - 1, true);
768
+ execIteration(priorKey, i - 1, true, context[priorKey]);
737
769
  }
738
770
  })();
739
771
  }
@@ -1970,9 +2002,10 @@ return /******/ (function(modules) { // webpackBootstrap
1970
2002
  exports.__esModule = true;
1971
2003
  exports.createProtoAccessControl = createProtoAccessControl;
1972
2004
  exports.resultIsAllowed = resultIsAllowed;
2005
+ exports.isPrototypeConstructor = isPrototypeConstructor;
1973
2006
  exports.resetLoggedProperties = resetLoggedProperties;
1974
2007
 
1975
- var _createNewLookupObject = __webpack_require__(75);
2008
+ var _utils = __webpack_require__(4);
1976
2009
 
1977
2010
  var _logger = __webpack_require__(71);
1978
2011
 
@@ -1981,23 +2014,28 @@ return /******/ (function(modules) { // webpackBootstrap
1981
2014
  var loggedProperties = _Object$create(null);
1982
2015
 
1983
2016
  function createProtoAccessControl(runtimeOptions) {
1984
- var defaultMethodWhiteList = _Object$create(null);
1985
- defaultMethodWhiteList['constructor'] = false;
1986
- defaultMethodWhiteList['__defineGetter__'] = false;
1987
- defaultMethodWhiteList['__defineSetter__'] = false;
1988
- defaultMethodWhiteList['__lookupGetter__'] = false;
1989
-
1990
- var defaultPropertyWhiteList = _Object$create(null);
2017
+ // Create an object with "null"-prototype to avoid truthy results on
2018
+ // prototype properties.
2019
+ var propertyWhiteList = _Object$create(null);
1991
2020
  // eslint-disable-next-line no-proto
1992
- defaultPropertyWhiteList['__proto__'] = false;
2021
+ propertyWhiteList['__proto__'] = false;
2022
+ _utils.extend(propertyWhiteList, runtimeOptions.allowedProtoProperties);
2023
+
2024
+ var methodWhiteList = _Object$create(null);
2025
+ methodWhiteList['constructor'] = false;
2026
+ methodWhiteList['__defineGetter__'] = false;
2027
+ methodWhiteList['__defineSetter__'] = false;
2028
+ methodWhiteList['__lookupGetter__'] = false;
2029
+ methodWhiteList['__lookupSetter__'] = false;
2030
+ _utils.extend(methodWhiteList, runtimeOptions.allowedProtoMethods);
1993
2031
 
1994
2032
  return {
1995
2033
  properties: {
1996
- whitelist: _createNewLookupObject.createNewLookupObject(defaultPropertyWhiteList, runtimeOptions.allowedProtoProperties),
2034
+ whitelist: propertyWhiteList,
1997
2035
  defaultValue: runtimeOptions.allowProtoPropertiesByDefault
1998
2036
  },
1999
2037
  methods: {
2000
- whitelist: _createNewLookupObject.createNewLookupObject(defaultMethodWhiteList, runtimeOptions.allowedProtoMethods),
2038
+ whitelist: methodWhiteList,
2001
2039
  defaultValue: runtimeOptions.allowProtoMethodsByDefault
2002
2040
  }
2003
2041
  };
@@ -2011,6 +2049,25 @@ return /******/ (function(modules) { // webpackBootstrap
2011
2049
  }
2012
2050
  }
2013
2051
 
2052
+ /**
2053
+ * Detect a prototype object's own "constructor" back-reference, e.g.
2054
+ * `Function.prototype.constructor === Function`. Because "constructor" is an
2055
+ * "own" property of such objects, it would otherwise bypass the prototype-access
2056
+ * checks and expose dangerous constructors (allowing arbitrary code execution).
2057
+ *
2058
+ * Only functions can be constructors, so other values are never treated as one
2059
+ * and their `prototype` is never read.
2060
+ *
2061
+ * @param {*} parent the object the property is being read from
2062
+ * @param {string} propertyName the property being looked up
2063
+ * @param {*} result the already-resolved value of `parent[propertyName]`
2064
+ * @returns {boolean} true if the lookup resolves `parent`'s own constructor
2065
+ */
2066
+
2067
+ function isPrototypeConstructor(parent, propertyName, result) {
2068
+ return propertyName === 'constructor' && typeof result === 'function' && parent === result.prototype;
2069
+ }
2070
+
2014
2071
  function checkWhiteList(protoAccessControlForType, propertyName) {
2015
2072
  if (protoAccessControlForType.whitelist[propertyName] !== undefined) {
2016
2073
  return protoAccessControlForType.whitelist[propertyName] === true;
@@ -2052,34 +2109,6 @@ return /******/ (function(modules) { // webpackBootstrap
2052
2109
 
2053
2110
  /***/ }),
2054
2111
  /* 75 */
2055
- /***/ (function(module, exports, __webpack_require__) {
2056
-
2057
- 'use strict';
2058
-
2059
- var _Object$create = __webpack_require__(73)['default'];
2060
-
2061
- exports.__esModule = true;
2062
- exports.createNewLookupObject = createNewLookupObject;
2063
-
2064
- var _utils = __webpack_require__(4);
2065
-
2066
- /**
2067
- * Create a new object with "null"-prototype to avoid truthy results on prototype properties.
2068
- * The resulting object can be used with "object[property]" to check if a property exists
2069
- * @param {...object} sources a varargs parameter of source objects that will be merged
2070
- * @returns {object}
2071
- */
2072
-
2073
- function createNewLookupObject() {
2074
- for (var _len = arguments.length, sources = Array(_len), _key = 0; _key < _len; _key++) {
2075
- sources[_key] = arguments[_key];
2076
- }
2077
-
2078
- return _utils.extend.apply(undefined, [_Object$create(null)].concat(sources));
2079
- }
2080
-
2081
- /***/ }),
2082
- /* 76 */
2083
2112
  /***/ (function(module, exports) {
2084
2113
 
2085
2114
  // Build out our basic SafeString type
@@ -2098,12 +2127,12 @@ return /******/ (function(modules) { // webpackBootstrap
2098
2127
  module.exports = exports['default'];
2099
2128
 
2100
2129
  /***/ }),
2101
- /* 77 */
2130
+ /* 76 */
2102
2131
  /***/ (function(module, exports, __webpack_require__) {
2103
2132
 
2104
2133
  'use strict';
2105
2134
 
2106
- var _Object$seal = __webpack_require__(78)['default'];
2135
+ var _Object$seal = __webpack_require__(77)['default'];
2107
2136
 
2108
2137
  var _Object$keys = __webpack_require__(59)['default'];
2109
2138
 
@@ -2131,7 +2160,7 @@ return /******/ (function(modules) { // webpackBootstrap
2131
2160
 
2132
2161
  var _helpers = __webpack_require__(9);
2133
2162
 
2134
- var _internalWrapHelper = __webpack_require__(81);
2163
+ var _internalWrapHelper = __webpack_require__(80);
2135
2164
 
2136
2165
  var _internalProtoAccess = __webpack_require__(72);
2137
2166
 
@@ -2180,16 +2209,26 @@ return /******/ (function(modules) { // webpackBootstrap
2180
2209
  }
2181
2210
  partial = env.VM.resolvePartial.call(this, partial, context, options);
2182
2211
 
2183
- var extendedOptions = Utils.extend({}, options, {
2184
- hooks: this.hooks,
2185
- protoAccessControl: this.protoAccessControl
2186
- });
2212
+ options.hooks = this.hooks;
2213
+ options.protoAccessControl = this.protoAccessControl;
2214
+
2215
+ var result = env.VM.invokePartial.call(this, partial, context, options);
2187
2216
 
2188
- var result = env.VM.invokePartial.call(this, partial, context, extendedOptions);
2217
+ // An empty result normally means the partial is template source that still
2218
+ // has to be compiled. A function partial has already been invoked, so an
2219
+ // empty result from it is a bug in that partial.
2220
+ if (result == null && Utils.isFunction(partial)) {
2221
+ throw new _exception2['default']('The partial ' + options.name + ' returned no output: partials must return a string');
2222
+ }
2189
2223
 
2190
2224
  if (result == null && env.compile) {
2225
+ // Only template source registered as a partial may be compiled here.
2226
+ // Anything else (e.g. an AST-shaped object) must not become code.
2227
+ if (typeof partial !== 'string') {
2228
+ throw new _exception2['default']('The partial ' + options.name + ' could not be compiled: partials must be strings or functions returning strings');
2229
+ }
2191
2230
  options.partials[options.name] = env.compile(partial, templateSpec.compilerOptions, env);
2192
- result = options.partials[options.name](context, extendedOptions);
2231
+ result = options.partials[options.name](context, options);
2193
2232
  }
2194
2233
  if (result != null) {
2195
2234
  if (options.indent) {
@@ -2224,7 +2263,12 @@ return /******/ (function(modules) { // webpackBootstrap
2224
2263
  if (result == null) {
2225
2264
  return result;
2226
2265
  }
2227
- if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
2266
+ // Own properties are trusted context data and returned as-is, except for
2267
+ // a prototype's own "constructor" back-reference (e.g.
2268
+ // Function.prototype.constructor === Function): that must still pass the
2269
+ // prototype-access deny list, otherwise the Function constructor becomes
2270
+ // reachable and arbitrary code can be executed.
2271
+ if (Object.prototype.hasOwnProperty.call(parent, propertyName) && !_internalProtoAccess.isPrototypeConstructor(parent, propertyName, result)) {
2228
2272
  return result;
2229
2273
  }
2230
2274
 
@@ -2238,7 +2282,7 @@ return /******/ (function(modules) { // webpackBootstrap
2238
2282
  for (var i = 0; i < len; i++) {
2239
2283
  var result = depths[i] && container.lookupProperty(depths[i], name);
2240
2284
  if (result != null) {
2241
- return depths[i][name];
2285
+ return result;
2242
2286
  }
2243
2287
  }
2244
2288
  },
@@ -2320,8 +2364,9 @@ return /******/ (function(modules) { // webpackBootstrap
2320
2364
 
2321
2365
  ret._setup = function (options) {
2322
2366
  if (!options.partial) {
2323
- var mergedHelpers = Utils.extend({}, env.helpers, options.helpers);
2324
- wrapHelpersToPassLookupProperty(mergedHelpers, container);
2367
+ var mergedHelpers = {};
2368
+ addHelpers(mergedHelpers, env.helpers, container);
2369
+ addHelpers(mergedHelpers, options.helpers, container);
2325
2370
  container.helpers = mergedHelpers;
2326
2371
 
2327
2372
  if (templateSpec.usePartial) {
@@ -2387,21 +2432,24 @@ return /******/ (function(modules) { // webpackBootstrap
2387
2432
  function resolvePartial(partial, context, options) {
2388
2433
  if (!partial) {
2389
2434
  if (options.name === '@partial-block') {
2390
- partial = options.data['partial-block'];
2435
+ partial = lookupOwnProperty(options.data, 'partial-block');
2391
2436
  } else {
2392
- partial = options.partials[options.name];
2437
+ partial = lookupOwnProperty(options.partials, options.name);
2393
2438
  }
2394
- } else if (!partial.call && !options.name) {
2395
- // This is a dynamic partial that returned a string
2439
+ } else if (typeof partial !== 'function' && !options.name) {
2440
+ // This is a dynamic partial that returned a name rather than a compiled
2441
+ // partial. Only functions are accepted as partials here; any other value
2442
+ // (including an object with a "call" property) is treated as a name, so
2443
+ // that context data can never be compiled as a template.
2396
2444
  options.name = partial;
2397
- partial = options.partials[partial];
2445
+ partial = lookupOwnProperty(options.partials, partial);
2398
2446
  }
2399
2447
  return partial;
2400
2448
  }
2401
2449
 
2402
2450
  function invokePartial(partial, context, options) {
2403
2451
  // Use the current closure context to save the partial-block if this partial
2404
- var currentPartialBlock = options.data && options.data['partial-block'];
2452
+ var currentPartialBlock = lookupOwnProperty(options.data, 'partial-block');
2405
2453
  options.partial = true;
2406
2454
  if (options.ids) {
2407
2455
  options.data.contextPath = options.ids[0] || options.data.contextPath;
@@ -2443,6 +2491,12 @@ return /******/ (function(modules) { // webpackBootstrap
2443
2491
  return '';
2444
2492
  }
2445
2493
 
2494
+ function lookupOwnProperty(obj, name) {
2495
+ if (obj && Object.prototype.hasOwnProperty.call(obj, name)) {
2496
+ return obj[name];
2497
+ }
2498
+ }
2499
+
2446
2500
  function initData(context, data) {
2447
2501
  if (!data || !('root' in data)) {
2448
2502
  data = data ? _base.createFrame(data) : {};
@@ -2460,9 +2514,10 @@ return /******/ (function(modules) { // webpackBootstrap
2460
2514
  return prog;
2461
2515
  }
2462
2516
 
2463
- function wrapHelpersToPassLookupProperty(mergedHelpers, container) {
2464
- _Object$keys(mergedHelpers).forEach(function (helperName) {
2465
- var helper = mergedHelpers[helperName];
2517
+ function addHelpers(mergedHelpers, helpers, container) {
2518
+ if (!helpers) return;
2519
+ _Object$keys(helpers).forEach(function (helperName) {
2520
+ var helper = helpers[helperName];
2466
2521
  mergedHelpers[helperName] = passLookupPropertyOption(helper, container);
2467
2522
  });
2468
2523
  }
@@ -2470,25 +2525,26 @@ return /******/ (function(modules) { // webpackBootstrap
2470
2525
  function passLookupPropertyOption(helper, container) {
2471
2526
  var lookupProperty = container.lookupProperty;
2472
2527
  return _internalWrapHelper.wrapHelper(helper, function (options) {
2473
- return Utils.extend({ lookupProperty: lookupProperty }, options);
2528
+ options.lookupProperty = lookupProperty;
2529
+ return options;
2474
2530
  });
2475
2531
  }
2476
2532
 
2477
2533
  /***/ }),
2478
- /* 78 */
2534
+ /* 77 */
2479
2535
  /***/ (function(module, exports, __webpack_require__) {
2480
2536
 
2481
- module.exports = { "default": __webpack_require__(79), __esModule: true };
2537
+ module.exports = { "default": __webpack_require__(78), __esModule: true };
2482
2538
 
2483
2539
  /***/ }),
2484
- /* 79 */
2540
+ /* 78 */
2485
2541
  /***/ (function(module, exports, __webpack_require__) {
2486
2542
 
2487
- __webpack_require__(80);
2543
+ __webpack_require__(79);
2488
2544
  module.exports = __webpack_require__(20).Object.seal;
2489
2545
 
2490
2546
  /***/ }),
2491
- /* 80 */
2547
+ /* 79 */
2492
2548
  /***/ (function(module, exports, __webpack_require__) {
2493
2549
 
2494
2550
  // 19.1.2.17 Object.seal(O)
@@ -2501,7 +2557,7 @@ return /******/ (function(modules) { // webpackBootstrap
2501
2557
  });
2502
2558
 
2503
2559
  /***/ }),
2504
- /* 81 */
2560
+ /* 80 */
2505
2561
  /***/ (function(module, exports) {
2506
2562
 
2507
2563
  'use strict';
@@ -2524,7 +2580,7 @@ return /******/ (function(modules) { // webpackBootstrap
2524
2580
  }
2525
2581
 
2526
2582
  /***/ }),
2527
- /* 82 */
2583
+ /* 81 */
2528
2584
  /***/ (function(module, exports) {
2529
2585
 
2530
2586
  /* global globalThis */
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handlebars-source
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.8
4
+ version: 4.7.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yehuda Katz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-02 00:00:00.000000000 Z
11
+ date: 2026-10-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Handlebars.js source code wrapper for (pre)compilation gems.
14
14
  email:
@@ -39,7 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  requirements: []
42
- rubygems_version: 3.4.10
42
+ rubygems_version: 3.4.19
43
43
  signing_key:
44
44
  specification_version: 4
45
45
  summary: Handlebars.js source code wrapper