@rive-app/webgl-single 2.4.2 → 2.4.3

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 (3) hide show
  1. package/package.json +1 -1
  2. package/rive.js +62 -4
  3. package/rive.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rive-app/webgl-single",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "description": "Rive's webgl based web api with bundled wasm.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.js CHANGED
@@ -160,7 +160,7 @@ if(k.preInit)for("function"==typeof k.preInit&&(k.preInit=[k.preInit]);0<k.preIn
160
160
  /* 2 */
161
161
  /***/ ((module) => {
162
162
 
163
- module.exports = JSON.parse('{"name":"@rive-app/webgl-single","version":"2.4.2","description":"Rive\'s webgl based web api with bundled wasm.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
163
+ module.exports = JSON.parse('{"name":"@rive-app/webgl-single","version":"2.4.3","description":"Rive\'s webgl based web api with bundled wasm.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
164
164
 
165
165
  /***/ }),
166
166
  /* 3 */
@@ -168,9 +168,13 @@ module.exports = JSON.parse('{"name":"@rive-app/webgl-single","version":"2.4.2",
168
168
 
169
169
  __webpack_require__.r(__webpack_exports__);
170
170
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
171
- /* harmony export */ registerTouchInteractions: () => (/* reexport safe */ _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__.registerTouchInteractions)
171
+ /* harmony export */ BLANK_URL: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__.BLANK_URL),
172
+ /* harmony export */ registerTouchInteractions: () => (/* reexport safe */ _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__.registerTouchInteractions),
173
+ /* harmony export */ sanitizeUrl: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__.sanitizeUrl)
172
174
  /* harmony export */ });
173
175
  /* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
176
+ /* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
177
+
174
178
 
175
179
 
176
180
 
@@ -307,6 +311,59 @@ var registerTouchInteractions = function (_a) {
307
311
  };
308
312
 
309
313
 
314
+ /***/ }),
315
+ /* 5 */
316
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
317
+
318
+ __webpack_require__.r(__webpack_exports__);
319
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
320
+ /* harmony export */ BLANK_URL: () => (/* binding */ BLANK_URL),
321
+ /* harmony export */ sanitizeUrl: () => (/* binding */ sanitizeUrl)
322
+ /* harmony export */ });
323
+ // Reference: https://github.com/braintree/sanitize-url/tree/main
324
+ var invalidProtocolRegex = /^([^\w]*)(javascript|data|vbscript)/im;
325
+ var htmlEntitiesRegex = /&#(\w+)(^\w|;)?/g;
326
+ var htmlCtrlEntityRegex = /&(newline|tab);/gi;
327
+ var ctrlCharactersRegex = /[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim;
328
+ var urlSchemeRegex = /^.+(:|&colon;)/gim;
329
+ var relativeFirstCharacters = [".", "/"];
330
+ var BLANK_URL = "about:blank";
331
+ function isRelativeUrlWithoutProtocol(url) {
332
+ return relativeFirstCharacters.indexOf(url[0]) > -1;
333
+ }
334
+ // adapted from https://stackoverflow.com/a/29824550/2601552
335
+ function decodeHtmlCharacters(str) {
336
+ var removedNullByte = str.replace(ctrlCharactersRegex, "");
337
+ return removedNullByte.replace(htmlEntitiesRegex, function (match, dec) {
338
+ return String.fromCharCode(dec);
339
+ });
340
+ }
341
+ function sanitizeUrl(url) {
342
+ if (!url) {
343
+ return BLANK_URL;
344
+ }
345
+ var sanitizedUrl = decodeHtmlCharacters(url)
346
+ .replace(htmlCtrlEntityRegex, "")
347
+ .replace(ctrlCharactersRegex, "")
348
+ .trim();
349
+ if (!sanitizedUrl) {
350
+ return BLANK_URL;
351
+ }
352
+ if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
353
+ return sanitizedUrl;
354
+ }
355
+ var urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex);
356
+ if (!urlSchemeParseResults) {
357
+ return sanitizedUrl;
358
+ }
359
+ var urlScheme = urlSchemeParseResults[0];
360
+ if (invalidProtocolRegex.test(urlScheme)) {
361
+ return BLANK_URL;
362
+ }
363
+ return sanitizedUrl;
364
+ }
365
+
366
+
310
367
  /***/ })
311
368
  /******/ ]);
312
369
  /************************************************************************/
@@ -1550,9 +1607,10 @@ var Rive = /** @class */ (function () {
1550
1607
  if (this.automaticallyHandleEvents) {
1551
1608
  var newAnchorTag = document.createElement("a");
1552
1609
  var _b = event_1, url = _b.url, target = _b.target;
1553
- url && newAnchorTag.setAttribute("href", url);
1610
+ var sanitizedUrl = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.sanitizeUrl)(url);
1611
+ url && newAnchorTag.setAttribute("href", sanitizedUrl);
1554
1612
  target && newAnchorTag.setAttribute("target", target);
1555
- if (url) {
1613
+ if (sanitizedUrl && sanitizedUrl !== _utils__WEBPACK_IMPORTED_MODULE_2__.BLANK_URL) {
1556
1614
  newAnchorTag.click();
1557
1615
  }
1558
1616
  }