@naturalcycles/nodejs-lib 12.47.1 → 12.47.2

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.
@@ -3,4 +3,4 @@ import { pipeline } from 'stream';
3
3
  /**
4
4
  * Promisified stream.pipeline()
5
5
  */
6
- export declare const _pipeline: typeof pipeline.__promisify__;
6
+ export declare let _pipeline: typeof pipeline.__promisify__;
@@ -7,3 +7,9 @@ const util_1 = require("util");
7
7
  * Promisified stream.pipeline()
8
8
  */
9
9
  exports._pipeline = (0, util_1.promisify)(stream_1.pipeline);
10
+ // Workaround https://github.com/nodejs/node/issues/40191
11
+ // todo: remove it when fix is released in 16.x and in AppEngine 16.x
12
+ if (process.version > 'v16.13') {
13
+ const { pipeline } = require('stream/promises');
14
+ exports._pipeline = ((streams) => pipeline(...streams));
15
+ }
@@ -88,12 +88,14 @@ function stringExtensions(joi) {
88
88
  ],
89
89
  validate(v, helpers, args) {
90
90
  // console.log('!!! stripHTML', args, v)
91
- const { strict } = args;
92
91
  const r = sanitize(v, {
93
- allowedTags: [], // no html tags allowed at all
92
+ allowedTags: [],
94
93
  // disallowedTagsMode: 'discard' // discard is default
94
+ parser: {
95
+ decodeEntities: false, // prevent decoding/changing of &<>"'
96
+ },
95
97
  });
96
- if (strict && r !== v) {
98
+ if (args.strict && r !== v) {
97
99
  return helpers.error('string.stripHTML', args);
98
100
  }
99
101
  return r; // return converted value (or the same, if there was nothing to sanitize)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "12.47.1",
3
+ "version": "12.47.2",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "docs-serve": "vuepress dev docs",
@@ -1,7 +1,16 @@
1
1
  import { pipeline } from 'stream'
2
2
  import { promisify } from 'util'
3
3
 
4
+ type AnyStream = NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream
5
+
4
6
  /**
5
7
  * Promisified stream.pipeline()
6
8
  */
7
- export const _pipeline = promisify(pipeline)
9
+ export let _pipeline = promisify(pipeline)
10
+
11
+ // Workaround https://github.com/nodejs/node/issues/40191
12
+ // todo: remove it when fix is released in 16.x and in AppEngine 16.x
13
+ if (process.version > 'v16.13') {
14
+ const { pipeline } = require('stream/promises')
15
+ _pipeline = ((streams: AnyStream[]) => pipeline(...streams)) as any
16
+ }
@@ -110,14 +110,16 @@ export function stringExtensions(joi: typeof Joi): Extension {
110
110
  ],
111
111
  validate(v: string, helpers, args: JoiStripHTMLOptions) {
112
112
  // console.log('!!! stripHTML', args, v)
113
- const { strict } = args
114
113
 
115
114
  const r = sanitize(v, {
116
115
  allowedTags: [], // no html tags allowed at all
117
116
  // disallowedTagsMode: 'discard' // discard is default
117
+ parser: {
118
+ decodeEntities: false, // prevent decoding/changing of &<>"'
119
+ },
118
120
  })
119
121
 
120
- if (strict && r !== v) {
122
+ if (args.strict && r !== v) {
121
123
  return helpers.error('string.stripHTML', args)
122
124
  }
123
125