postcss 8.5.11 → 8.5.12

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
@@ -351,6 +351,11 @@ declare namespace postcss {
351
351
  * to generate correct source maps.
352
352
  */
353
353
  to?: string
354
+
355
+ /**
356
+ * Disable source map file protections.
357
+ */
358
+ unsafeMap?: boolean
354
359
  }
355
360
 
356
361
  export type Postcss = typeof postcss
@@ -16,6 +16,7 @@ function fromBase64(str) {
16
16
  class PreviousMap {
17
17
  constructor(css, opts) {
18
18
  if (opts.map === false) return
19
+ if (opts.unsafeMap) this.unsafeMap = true
19
20
  this.loadAnnotation(css)
20
21
  this.inline = this.startWith(this.annotation, 'data:')
21
22
 
@@ -30,7 +31,7 @@ class PreviousMap {
30
31
 
31
32
  consumer() {
32
33
  if (!this.consumerCache) {
33
- this.consumerCache = new SourceMapConsumer(this.text)
34
+ this.consumerCache = new SourceMapConsumer(this.json || this.text)
34
35
  }
35
36
  return this.consumerCache
36
37
  }
@@ -83,7 +84,13 @@ class PreviousMap {
83
84
  }
84
85
  }
85
86
 
86
- loadFile(path) {
87
+ loadFile(path, cssFile, trusted) {
88
+ /* c8 ignore next 5 */
89
+ if (!trusted && !this.unsafeMap) {
90
+ if (!/\.map$/i.test(path)) {
91
+ return undefined
92
+ }
93
+ }
87
94
  this.root = dirname(path)
88
95
  if (existsSync(path)) {
89
96
  this.mapFile = path
@@ -100,7 +107,7 @@ class PreviousMap {
100
107
  } else if (typeof prev === 'function') {
101
108
  let prevPath = prev(file)
102
109
  if (prevPath) {
103
- let map = this.loadFile(prevPath)
110
+ let map = this.loadFile(prevPath, file, true)
104
111
  if (!map) {
105
112
  throw new Error(
106
113
  'Unable to load previous source map: ' + prevPath.toString()
@@ -124,7 +131,16 @@ class PreviousMap {
124
131
  } else if (this.annotation) {
125
132
  let map = this.annotation
126
133
  if (file) map = join(dirname(file), map)
127
- return this.loadFile(map)
134
+ let unknown = this.loadFile(map, file, false)
135
+ if (unknown) {
136
+ try {
137
+ /* c8 ignore next 4 */
138
+ this.json = JSON.parse(unknown.replace(/^\)]}'[^\n]*\n/, ''))
139
+ } catch {
140
+ return undefined
141
+ }
142
+ }
143
+ return unknown
128
144
  }
129
145
  }
130
146
 
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.11'
10
+ this.version = '8.5.12'
11
11
  this.plugins = this.normalize(plugins)
12
12
  }
13
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss",
3
- "version": "8.5.11",
3
+ "version": "8.5.12",
4
4
  "description": "Tool for transforming styles with JS plugins",
5
5
  "keywords": [
6
6
  "css",