Skip to content

Commit

Permalink
Ignore invalid quoted-attribute attributes (missing quotes)
Browse files Browse the repository at this point in the history
Related to #6203
  • Loading branch information
robwalch committed Feb 14, 2024
1 parent 42c44f7 commit ef79668
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/utils/attr-list.ts
Expand Up @@ -177,9 +177,9 @@ export class AttrList {
case 'VIDEO':
case 'X-ASSET-LIST':
case 'X-ASSET-URI':
logger.warn(
`${input}: attribute ${name} has invalid value format (missing quotes).`,
);
// Since we are not checking tag:attribute combination, just warn rather than ignoring attribute
logger.warn(`${input}: attribute ${name} is missing quotes`);
// continue;
}
}
attrs[name] = value;
Expand Down
54 changes: 51 additions & 3 deletions tests/unit/loader/date-range.ts
Expand Up @@ -44,6 +44,27 @@ describe('DateRange class', function () {
const endOnNextWithNoClass = new AttrList(
'ID="ad3",START-DATE="2022-01-01T00:00:00.100Z",END-ON-NEXT=YES',
);
const cueWithPre = new AttrList(
'ID="mid1",CLASS="com.apple.hls.interstitial",CUE="PRE",START-DATE="2024-01-12T10:00:10.000Z",DURATION=15.0,X-ASSET-URI="b.m3u8"',
);
const cueWithPost = new AttrList(
'ID="mid1",CLASS="com.apple.hls.interstitial",CUE="POST",START-DATE="2024-01-12T10:00:10.000Z",DURATION=15.0,X-ASSET-URI="b.m3u8"',
);
const cueWithPreOnce = new AttrList(
'ID="mid1",CLASS="com.apple.hls.interstitial",CUE="PRE,ONCE",START-DATE="2024-01-12T10:00:10.000Z",DURATION=15.0,X-ASSET-URI="b.m3u8"',
);
const cueWithPostOnce = new AttrList(
'ID="mid1",CLASS="com.apple.hls.interstitial",CUE="POST,ONCE",START-DATE="2024-01-12T10:00:10.000Z",DURATION=15.0,X-ASSET-URI="b.m3u8"',
);
const cueWithPreAndPost = new AttrList(
'ID="mid1",CLASS="com.apple.hls.interstitial",CUE="PRE,POST",START-DATE="2024-01-12T10:00:10.000Z",DURATION=15.0,X-ASSET-URI="b.m3u8"',
);
const invalidQuotedAttributeId = new AttrList(
'ID=bad,START-DATE="2020-01-02T21:55:44.000Z",DURATION=1.0',
);
const invalidQuotedAttributeStartDate = new AttrList(
'ID="ok",START-DATE=2020-01-02T21:55:44.000Z,DURATION=1.0',
);

it('parses id, class, date, duration, and end-on-next attributes', function () {
const dateRangeDuration = new DateRange(startDateAndDuration);
Expand Down Expand Up @@ -103,8 +124,6 @@ describe('DateRange class', function () {
expect(scteIn.isValid).to.equal(true);
});

it('parses the CUE attribute PRE, POST, and ONCE Trigger Identifiers', function () {});

describe('isInterstitial', function () {
it('identifies Interstitial DateRange tags with CLASS="com.apple.hls.interstitial"', function () {
expect(new DateRange(startDateAndDuration).isInterstitial).to.be.true;
Expand Down Expand Up @@ -173,6 +192,35 @@ describe('DateRange class', function () {
);
});

it('MUST NOT include both PRE and POST CUE Trigger Identifiers', function () {});
it('parses the CUE attribute PRE, POST, and ONCE Trigger Identifiers', function () {
const pre = new DateRange(cueWithPre);
const post = new DateRange(cueWithPost);
const preOnce = new DateRange(cueWithPreOnce);
const postOnce = new DateRange(cueWithPostOnce);
expect(pre.isValid).to.equal(true, JSON.stringify(pre));
expect(post.isValid).to.equal(true, JSON.stringify(post));
expect(preOnce.isValid).to.equal(true, JSON.stringify(preOnce));
expect(postOnce.isValid).to.equal(true, JSON.stringify(postOnce));
});

it('MUST NOT include both PRE and POST CUE Trigger Identifiers', function () {
const preAndPost = new DateRange(cueWithPreAndPost);
expect(preAndPost.isValid).to.equal(
false,
`Expected DateRange with CUE to have PRE or POST enumerated string values, but not both\n${JSON.stringify(
preAndPost,
)}`,
);
});

// it('considers tags invalid when attributes whose values are expected to be quoted-strings are missing quotes', function () {
// const invalidId = new DateRange(invalidQuotedAttributeId);
// expect(invalidId.isValid).to.equal(false, 'ID is missing quotes');
// const invalidDate = new DateRange(invalidQuotedAttributeStartDate);
// expect(invalidDate.isValid).to.equal(
// false,
// 'START-DATE is missing quotes',
// );
// });
});
});

0 comments on commit ef79668

Please sign in to comment.