Skip to content

Commit e691f5f

Browse files
authored
Merge commit from fork
1 parent b1d9f1a commit e691f5f

File tree

8 files changed

+107
-35
lines changed

8 files changed

+107
-35
lines changed

.github/workflows/publish.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
name: Node.js Package
2-
31
on:
42
release:
53
types: [created]
@@ -12,17 +10,26 @@ permissions:
1210
jobs:
1311
publish-npm:
1412
runs-on: ubuntu-latest
13+
env:
14+
GH_TOKEN: ${{ github.token }}
1515
steps:
1616
- uses: actions/checkout@v6
1717
- run: corepack enable
1818
- uses: actions/setup-node@v6
1919
with:
20-
node-version: 22
20+
node-version: 24
2121
registry-url: https://registry.npmjs.org
2222
- run: yarn install
2323
- run: |
24-
if jq -r .version <package.json | grep -q \\-rc.; then
24+
VERSION=$(jq -r .version <package.json)
25+
if [[ "$VERSION" = *"-rc."* ]]; then
2526
yarn npm publish --access public --tag rc
2627
else
27-
yarn npm publish --access public
28+
LATEST_VERSION="$(gh release view --json tagName -q '.tagName' --repo ${{ github.repository }})"
29+
if [[ "${{ github.ref_name }}" = "$LATEST_VERSION" ]]; then
30+
yarn npm publish --access public
31+
else
32+
MAJOR="$(awk -F '.' '{ print $1 }' <<< "$VERSION")"
33+
npm publish --access public --tag "v$MAJOR"
34+
fi
2835
fi

.yarn/patches/sax-npm-1.4.1-503b1923cb.patch renamed to .yarn/patches/sax-npm-1.5.0-d40bca2226.patch

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
diff --git a/lib/sax.js b/lib/sax.js
2-
index 122ad8e5a478339d56fc86d00d21c5d142739f0e..2557c46482ff651026436cc6c7142ebfe68ddfc5 100644
2+
index d35adf1a319b7f064d7a7e43c46630ed5ef587ff..4c5a08844f3be4ddceb12285d3fd133213dcc7e0 100644
33
--- a/lib/sax.js
44
+++ b/lib/sax.js
5-
@@ -1,8 +1,6 @@
6-
;(function (sax) { // wrapper for non-node envs
7-
sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }
5+
@@ -4,8 +4,6 @@
6+
return new SAXParser(strict, opt)
7+
}
88
sax.SAXParser = SAXParser
99
- sax.SAXStream = SAXStream
1010
- sax.createStream = createStream
1111

1212
// When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
1313
// When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
14-
@@ -164,111 +162,6 @@
15-
flush: function () { flushBuffers(this) }
14+
@@ -191,123 +189,6 @@
15+
},
1616
}
1717

1818
- var Stream
@@ -27,11 +27,11 @@ index 122ad8e5a478339d56fc86d00d21c5d142739f0e..2557c46482ff651026436cc6c7142ebf
2727
- return ev !== 'error' && ev !== 'end'
2828
- })
2929
-
30-
- function createStream (strict, opt) {
30+
- function createStream(strict, opt) {
3131
- return new SAXStream(strict, opt)
3232
- }
3333
-
34-
- function SAXStream (strict, opt) {
34+
- function SAXStream(strict, opt) {
3535
- if (!(this instanceof SAXStream)) {
3636
- return new SAXStream(strict, opt)
3737
- }
@@ -72,26 +72,27 @@ index 122ad8e5a478339d56fc86d00d21c5d142739f0e..2557c46482ff651026436cc6c7142ebf
7272
- me.on(ev, h)
7373
- },
7474
- enumerable: true,
75-
- configurable: false
75+
- configurable: false,
7676
- })
7777
- })
7878
- }
7979
-
8080
- SAXStream.prototype = Object.create(Stream.prototype, {
8181
- constructor: {
82-
- value: SAXStream
83-
- }
82+
- value: SAXStream,
83+
- },
8484
- })
8585
-
8686
- SAXStream.prototype.write = function (data) {
87-
- if (typeof Buffer === 'function' &&
87+
- if (
88+
- typeof Buffer === 'function' &&
8889
- typeof Buffer.isBuffer === 'function' &&
89-
- Buffer.isBuffer(data)) {
90+
- Buffer.isBuffer(data)
91+
- ) {
9092
- if (!this._decoder) {
91-
- var SD = require('string_decoder').StringDecoder
92-
- this._decoder = new SD('utf8')
93+
- this._decoder = new TextDecoder('utf8')
9394
- }
94-
- data = this._decoder.write(data)
95+
- data = this._decoder.decode(data, { stream: true })
9596
- }
9697
-
9798
- this._parser.write(data.toString())
@@ -103,6 +104,14 @@ index 122ad8e5a478339d56fc86d00d21c5d142739f0e..2557c46482ff651026436cc6c7142ebf
103104
- if (chunk && chunk.length) {
104105
- this.write(chunk)
105106
- }
107+
- // Flush any remaining decoded data from the TextDecoder
108+
- if (this._decoder) {
109+
- var remaining = this._decoder.decode()
110+
- if (remaining) {
111+
- this._parser.write(remaining)
112+
- this.emit('data', remaining)
113+
- }
114+
- }
106115
- this._parser.end()
107116
- return true
108117
- }
@@ -111,7 +120,10 @@ index 122ad8e5a478339d56fc86d00d21c5d142739f0e..2557c46482ff651026436cc6c7142ebf
111120
- var me = this
112121
- if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) {
113122
- me._parser['on' + ev] = function () {
114-
- var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments)
123+
- var args =
124+
- arguments.length === 1 ?
125+
- [arguments[0]]
126+
- : Array.apply(null, arguments)
115127
- args.splice(0, 0, ev)
116128
- me.emit.apply(me, args)
117129
- }

lib/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
* @type {string}
55
* @since 4.0.0
66
*/
7-
export const VERSION = '4.0.0';
7+
export const VERSION = '4.0.1';

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"packageManager": "yarn@3.8.7",
33
"name": "svgo",
4-
"version": "4.0.0",
4+
"version": "4.0.1",
55
"description": "SVGO is a Node.js library and command-line application for optimizing vector images.",
66
"license": "MIT",
77
"type": "module",
@@ -108,7 +108,7 @@
108108
"css-what": "^6.1.0",
109109
"csso": "^5.0.5",
110110
"picocolors": "^1.1.1",
111-
"sax": "^1.4.1"
111+
"sax": "^1.5.0"
112112
},
113113
"devDependencies": {
114114
"@eslint/js": "^9.25.1",
@@ -139,6 +139,6 @@
139139
"typescript": "^5.8.3"
140140
},
141141
"resolutions": {
142-
"sax@^1.4.1": "patch:sax@npm%3A1.4.1#./.yarn/patches/sax-npm-1.4.1-503b1923cb.patch"
142+
"sax@^1.5.0": "patch:sax@npm%3A1.5.0#./.yarn/patches/sax-npm-1.5.0-d40bca2226.patch"
143143
}
144144
}

test/svgo/billion-laughs-flat.svg

Lines changed: 8 additions & 0 deletions
Loading

test/svgo/billion-laughs.svg

Lines changed: 15 additions & 0 deletions
Loading

test/svgo/billion-laughs.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { readFile } from 'node:fs/promises';
2+
import path from 'path';
3+
import { fileURLToPath } from 'url';
4+
import { optimize } from '../../lib/svgo.js';
5+
6+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
7+
8+
describe('svgo', () => {
9+
it('should throw on excessive expansion depth', async () => {
10+
const original = await readFile(
11+
path.join(__dirname, 'billion-laughs.svg'),
12+
'utf-8',
13+
);
14+
15+
expect(() => {
16+
optimize(original);
17+
}).toThrow('Parsed entity depth exceeds max entity depth');
18+
});
19+
20+
it('should throw on excessive expansion count', async () => {
21+
const original = await readFile(
22+
path.join(__dirname, 'billion-laughs-flat.svg'),
23+
'utf-8',
24+
);
25+
26+
expect(() => {
27+
optimize(original);
28+
}).toThrow('Parsed entity count exceeds max entity count');
29+
});
30+
});

yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5451,17 +5451,17 @@ __metadata:
54515451
languageName: node
54525452
linkType: hard
54535453

5454-
"sax@npm:1.4.1":
5455-
version: 1.4.1
5456-
resolution: "sax@npm:1.4.1"
5457-
checksum: 3ad64df16b743f0f2eb7c38ced9692a6d924f1cd07bbe45c39576c2cf50de8290d9d04e7b2228f924c7d05fecc4ec5cf651423278e0c7b63d260c387ef3af84a
5454+
"sax@npm:1.5.0":
5455+
version: 1.5.0
5456+
resolution: "sax@npm:1.5.0"
5457+
checksum: e143cbeb6ca59345db142d97d1bbb620553beb8b166eda36ffeaba4b01af47dcf0423cd8781d0805b75feea69462cf80d0db7bf0a7e6dd87b711fda51b9153df
54585458
languageName: node
54595459
linkType: hard
54605460

5461-
"sax@patch:sax@npm%3A1.4.1#./.yarn/patches/sax-npm-1.4.1-503b1923cb.patch::locator=svgo%40workspace%3A.":
5462-
version: 1.4.1
5463-
resolution: "sax@patch:sax@npm%3A1.4.1#./.yarn/patches/sax-npm-1.4.1-503b1923cb.patch::version=1.4.1&hash=ad106d&locator=svgo%40workspace%3A."
5464-
checksum: 511be280ca9f1d474466aa165a7e6b50fc70e2de2f263462f60358a9f0661cf36c8f334234813e438d61676374e7aa551a6c81bcecb763e3d3914e2f627a8a51
5461+
"sax@patch:sax@npm%3A1.5.0#./.yarn/patches/sax-npm-1.5.0-d40bca2226.patch::locator=svgo%40workspace%3A.":
5462+
version: 1.5.0
5463+
resolution: "sax@patch:sax@npm%3A1.5.0#./.yarn/patches/sax-npm-1.5.0-d40bca2226.patch::version=1.5.0&hash=76ff30&locator=svgo%40workspace%3A."
5464+
checksum: e284b1d2584a046258c323837a3c8d6e10d37468c5fbea9c092d3106761f57b8a5947e63bbf8b27b1930e7f9adb439f2a3c31d4c316495b8d7830fb03c8cb9e8
54655465
languageName: node
54665466
linkType: hard
54675467

@@ -5858,7 +5858,7 @@ __metadata:
58585858
prettier: ^3.5.3
58595859
rimraf: ^5.0.10
58605860
rollup: ^4.22.4
5861-
sax: ^1.4.1
5861+
sax: ^1.5.0
58625862
tar-stream: ^3.1.7
58635863
tsd: ^0.32.0
58645864
typescript: ^5.8.3

0 commit comments

Comments
 (0)