Skip to content

Commit da2c049

Browse files
committed
Merge branch 'bugfix/ARSN-554/fix_empty_tag_value_crash' into q/8.2
2 parents 2ff8e72 + feabbdd commit da2c049

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

lib/s3middleware/tagging.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const _validator = {
4545
validateTagObjectStructure: (tag: BucketTag) => tag
4646
&& Object.keys(tag).length === 2
4747
&& typeof tag.Key === 'string' && typeof tag.Value === 'string'
48-
&& tag.Key.length >= 1 && tag.Value.length >= 1,
48+
&& tag.Key.length >= 1,
4949

5050
validateXMLStructure: (result: any) =>
5151
result && Object.keys(result).length === 1 &&

tests/unit/s3middleware/tagging.spec.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const assert = require('assert');
2-
const { areTagsValid, _validator } = require('../../../lib/s3middleware/tagging');
2+
const werelogs = require('werelogs');
3+
const { areTagsValid, _validator, parseTagXml } = require('../../../lib/s3middleware/tagging');
34

45
describe('tagging validator', () => {
56
it('validates keys and values are less than 128 and 256', () => {
@@ -68,6 +69,14 @@ describe('areTagsValid', () => {
6869
assert.strictEqual(result, false);
6970
});
7071

72+
it('should return true for tags with empty Value', () => {
73+
const validTags = [
74+
{ Key: 'key1', Value: '' }
75+
];
76+
const result = areTagsValid(validTags);
77+
assert.strictEqual(result, true);
78+
});
79+
7180
it('should return false for tags with duplicate keys', () => {
7281
const invalidTags = [
7382
{ Key: 'key1', Value: 'value1' },
@@ -93,3 +102,16 @@ describe('areTagsValid', () => {
93102
assert.strictEqual(result, false);
94103
});
95104
});
105+
106+
describe('parseTagXml', () => {
107+
const log = new werelogs.Logger('test');
108+
109+
it('should parse tags with empty values from XML', (done) => {
110+
const xml = '<Tagging><TagSet><Tag><Key>key1</Key><Value></Value></Tag></TagSet></Tagging>';
111+
parseTagXml(xml, log, (err, result) => {
112+
assert.ifError(err);
113+
assert.deepStrictEqual(result, { key1: '' });
114+
done();
115+
});
116+
});
117+
});

0 commit comments

Comments
 (0)