postcss 8.5.17 → 8.5.19

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.
package/lib/postcss.d.ts CHANGED
@@ -229,7 +229,7 @@ declare namespace postcss {
229
229
  export interface Parser<RootNode = Document | Root> {
230
230
  (
231
231
  css: { toString(): string } | string,
232
- opts?: Pick<ProcessOptions, 'document' | 'from' | 'map'>
232
+ opts?: Pick<ProcessOptions, 'document' | 'from' | 'map' | 'unsafeMap'>
233
233
  ): RootNode
234
234
  }
235
235
 
@@ -354,6 +354,9 @@ declare namespace postcss {
354
354
 
355
355
  /**
356
356
  * Disable source map file protections.
357
+ *
358
+ * By default source map is limited only for `.map` files
359
+ * in the `from` folder.
357
360
  */
358
361
  unsafeMap?: boolean
359
362
  }
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  let { existsSync, readFileSync } = require('fs')
4
- let { dirname, join } = require('path')
4
+ let { dirname, isAbsolute, join, relative, sep } = require('path')
5
5
  let { SourceMapConsumer, SourceMapGenerator } = require('source-map-js')
6
6
 
7
7
  function fromBase64(str) {
@@ -85,11 +85,20 @@ class PreviousMap {
85
85
  }
86
86
 
87
87
  loadFile(path, cssFile, trusted) {
88
- /* c8 ignore next 5 */
89
88
  if (!trusted && !this.unsafeMap) {
90
89
  if (!/\.map$/i.test(path)) {
91
90
  return undefined
92
91
  }
92
+ if (cssFile) {
93
+ let relativePath = relative(dirname(cssFile), path)
94
+ if (
95
+ relativePath === '..' ||
96
+ relativePath.startsWith('..' + sep) ||
97
+ isAbsolute(relativePath)
98
+ ) {
99
+ return undefined
100
+ }
101
+ }
93
102
  }
94
103
  this.root = dirname(path)
95
104
  if (existsSync(path)) {
package/lib/processor.js CHANGED
@@ -7,7 +7,7 @@ let Root = require('./root')
7
7
 
8
8
  class Processor {
9
9
  constructor(plugins = []) {
10
- this.version = '8.5.17'
10
+ this.version = '8.5.19'
11
11
  this.plugins = this.normalize(plugins)
12
12
  }
13
13
 
package/lib/root.js CHANGED
@@ -12,6 +12,19 @@ class Root extends Container {
12
12
  }
13
13
 
14
14
  normalize(child, sample, type) {
15
+ let keepBefore = new Set()
16
+ for (let node of Array.isArray(child) ? child : [child]) {
17
+ if (
18
+ node &&
19
+ typeof node === 'object' &&
20
+ !node.parent &&
21
+ node.raws &&
22
+ typeof node.raws.before !== 'undefined'
23
+ ) {
24
+ keepBefore.add(node.raws)
25
+ }
26
+ }
27
+
15
28
  let nodes = super.normalize(child)
16
29
 
17
30
  if (sample) {
@@ -23,7 +36,9 @@ class Root extends Container {
23
36
  }
24
37
  } else if (this.first !== sample) {
25
38
  for (let node of nodes) {
26
- node.raws.before = sample.raws.before
39
+ if (!keepBefore.has(node.raws)) {
40
+ node.raws.before = sample.raws.before
41
+ }
27
42
  }
28
43
  }
29
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss",
3
- "version": "8.5.17",
3
+ "version": "8.5.19",
4
4
  "description": "Tool for transforming styles with JS plugins",
5
5
  "keywords": [
6
6
  "css",