Skip to content

Commit 34c1451

Browse files
committed
2.6.3-alpha.3
1 parent 19c0368 commit 34c1451

File tree

16 files changed

+22
-86
lines changed

16 files changed

+22
-86
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ This changelog also contains important changes in dependencies.
99

1010
## [Unreleased]
1111

12+
## [2.6.3-alpha.3] - 2026-01-09
13+
14+
- fix: enhance `cropByBBox()` input validation to prevent panics
15+
- chore: `[email protected]` requires rustc 1.88
16+
1217
## [2.6.3-alpha.2] - 2025-09-26
1318

1419
- feat: the `padding` of `cropByBBox()` no longer scales with image dimensions
@@ -660,7 +665,9 @@ The first official version, use [resvg 0.18.0](https://github.com/RazrFalcon/res
660665
- Support custom fonts and system fonts.
661666
- Supports setting the background color of PNG.
662667

663-
[unreleased]: https://github.com/yisibl/resvg-js/compare/2.6.3-alpha.1...HEAD
668+
[unreleased]: https://github.com/yisibl/resvg-js/compare/2.6.3-alpha.2...HEAD
669+
[2.6.3-alpha.3]: https://github.com/yisibl/resvg-js/compare/v2.6.3-alpha.2...v2.6.3-alpha.3
670+
[2.6.3-alpha.2]: https://github.com/yisibl/resvg-js/compare/v2.6.3-alpha.1...v2.6.3-alpha.2
664671
[2.6.3-alpha.1]: https://github.com/yisibl/resvg-js/compare/v2.6.3-alpha.0...v2.6.3-alpha.1
665672
[2.6.3-alpha.0]: https://github.com/yisibl/resvg-js/compare/v2.6.2...v2.6.3-alpha.0
666673
[2.6.2]: https://github.com/yisibl/resvg-js/compare/v2.6.1...v2.6.2

__test__/index.spec.ts

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -751,77 +751,6 @@ test('cropByBBox with fitTo should handle zero/negative bbox dimensions', (t) =>
751751
}
752752
})
753753

754-
test('cropByBBox should handle invalid padding values', (t) => {
755-
const svg = `<svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg">
756-
<rect fill="green" x="50" y="50" width="200" height="200"/>
757-
</svg>`
758-
const resvg = new Resvg(svg)
759-
const bbox = resvg.getBBox()!
760-
761-
// Invalid values should silently use 0, not throw
762-
t.notThrows(() => resvg.cropByBBox(bbox, NaN))
763-
t.notThrows(() => resvg.cropByBBox(bbox, Infinity))
764-
t.notThrows(() => resvg.cropByBBox(bbox, -10))
765-
766-
// padding >= half of dimensions should produce transparent image, not panic
767-
t.notThrows(() => resvg.cropByBBox(bbox, bbox.width))
768-
})
769-
770-
test('cropByBBox should handle zero/negative bbox dimensions', (t) => {
771-
const svg = `<svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg">
772-
<rect fill="green" x="50" y="50" width="200" height="200"/>
773-
</svg>`
774-
const resvg = new Resvg(svg)
775-
const bbox = resvg.getBBox()!
776-
777-
// These should not panic (validation happens in Rust)
778-
const zeroBbox = { ...bbox, width: 0 }
779-
const negativeBbox = { ...bbox, width: -10 }
780-
781-
// napi-rs may reject invalid BBox objects at type conversion level (InvalidArg)
782-
// or at Rust validation level (silently ignored). Both are acceptable.
783-
try {
784-
resvg.cropByBBox(zeroBbox as any)
785-
t.pass('Zero width bbox handled without panic')
786-
} catch (e: any) {
787-
t.true(e.code === 'InvalidArg', 'Zero width bbox rejected at type level')
788-
}
789-
790-
try {
791-
resvg.cropByBBox(negativeBbox as any)
792-
t.pass('Negative width bbox handled without panic')
793-
} catch (e: any) {
794-
t.true(e.code === 'InvalidArg', 'Negative width bbox rejected at type level')
795-
}
796-
})
797-
798-
test('cropByBBox with fitTo should handle zero/negative bbox dimensions', (t) => {
799-
const svg = `<svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg">
800-
<rect fill="green" x="50" y="50" width="200" height="200"/>
801-
</svg>`
802-
const resvg = new Resvg(svg, { fitTo: { mode: 'width', value: 500 } })
803-
const bbox = resvg.getBBox()!
804-
805-
// Modify bbox to have zero/negative dimensions
806-
const zeroBbox = { ...bbox, width: 0 }
807-
const negativeBbox = { ...bbox, width: -10 }
808-
809-
// These should not panic with fitTo option
810-
try {
811-
resvg.cropByBBox(zeroBbox as any)
812-
t.pass('Zero width bbox with fitTo handled without panic')
813-
} catch (e: any) {
814-
t.true(e.code === 'InvalidArg', 'Zero width bbox rejected at type level')
815-
}
816-
817-
try {
818-
resvg.cropByBBox(negativeBbox as any)
819-
t.pass('Negative width bbox with fitTo handled without panic')
820-
} catch (e: any) {
821-
t.true(e.code === 'InvalidArg', 'Negative width bbox rejected at type level')
822-
}
823-
})
824-
825754
test('should render using font buffer provided by options', async (t) => {
826755
const svg = `<svg width='480' height='150' viewBox='-20 -80 550 100' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
827756
<text x='0' y='0' font-size='100' fill='#000'>Font Buffer</text>

npm/android-arm-eabi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@resvg/resvg-js-android-arm-eabi",
3-
"version": "2.6.3-alpha.2",
3+
"version": "2.6.3-alpha.3",
44
"os": [
55
"android"
66
],

npm/android-arm64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@resvg/resvg-js-android-arm64",
3-
"version": "2.6.3-alpha.2",
3+
"version": "2.6.3-alpha.3",
44
"os": [
55
"android"
66
],

npm/darwin-arm64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@resvg/resvg-js-darwin-arm64",
3-
"version": "2.6.3-alpha.2",
3+
"version": "2.6.3-alpha.3",
44
"os": [
55
"darwin"
66
],

npm/darwin-x64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@resvg/resvg-js-darwin-x64",
3-
"version": "2.6.3-alpha.2",
3+
"version": "2.6.3-alpha.3",
44
"os": [
55
"darwin"
66
],

npm/linux-arm-gnueabihf/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@resvg/resvg-js-linux-arm-gnueabihf",
3-
"version": "2.6.3-alpha.2",
3+
"version": "2.6.3-alpha.3",
44
"os": [
55
"linux"
66
],

npm/linux-arm64-gnu/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@resvg/resvg-js-linux-arm64-gnu",
3-
"version": "2.6.3-alpha.2",
3+
"version": "2.6.3-alpha.3",
44
"os": [
55
"linux"
66
],

npm/linux-arm64-musl/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@resvg/resvg-js-linux-arm64-musl",
3-
"version": "2.6.3-alpha.2",
3+
"version": "2.6.3-alpha.3",
44
"os": [
55
"linux"
66
],

npm/linux-x64-gnu/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@resvg/resvg-js-linux-x64-gnu",
3-
"version": "2.6.3-alpha.2",
3+
"version": "2.6.3-alpha.3",
44
"os": [
55
"linux"
66
],

0 commit comments

Comments
 (0)