Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax record terminate char spec #46

Merged
merged 1 commit into from
Mar 27, 2020

Conversation

at-wat
Copy link
Member

@at-wat at-wat commented Mar 26, 2020

Allow single '\n' as a record termination since RFC 4566 says:

parsers SHOULD be tolerant and also accept records terminated with
a single newline character.

Allow to have empty lines.
Other SDP parsers (e.g. one in VLC media player) allow empty lines.

Reference issue

Fixes #44

@at-wat at-wat mentioned this pull request Mar 26, 2020
@codecov
Copy link

codecov bot commented Mar 26, 2020

Codecov Report

Merging #46 into master will increase coverage by 0.10%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #46      +/-   ##
==========================================
+ Coverage   63.98%   64.08%   +0.10%     
==========================================
  Files          11       11              
  Lines        1080     1086       +6     
==========================================
+ Hits          691      696       +5     
- Misses        297      298       +1     
  Partials       92       92              
Flag Coverage Δ
#go 64.08% <66.66%> (+0.10%) ⬆️
#wasm 64.08% <66.66%> (+0.10%) ⬆️
Impacted Files Coverage Δ
unmarshal.go 60.98% <ø> (+0.54%) ⬆️
util.go 65.89% <66.66%> (-1.17%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2fd3281...0bffc66. Read the comment docs.

@at-wat at-wat force-pushed the relax-record-termination-char-spec branch 6 times, most recently from a6dc5d0 to 99a7e4d Compare March 26, 2020 11:56
// The expected value looks a bit different for the same reason as mentioned
// above regarding RepeatTimes.
TimeZonesSDP = TimingSDP +
"r=2882844526 -1h 2898848070 0\r\n"
"z=2882844526 -1h 2898848070 0\r\n"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure, but I think TimeZone should be z=.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you find the reference for this in the RFC? I am pretty sure it was r. Other than that the PR seems fine and the unittests are passing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://tools.ietf.org/html/rfc4566#section-5.11
TimeZones field is z=, but in

sdp/unmarshal_test.go

Lines 240 to 253 in 2fd3281

func TestUnmarshalTimeZones(t *testing.T) {
sd := &SessionDescription{}
if err := sd.Unmarshal([]byte(TimeZonesSDP)); err != nil {
t.Errorf("error: %v", err)
}
actual, err := sd.Marshal()
if got, want := err, error(nil); got != want {
t.Fatalf("Marshal(): err=%v, want %v", got, want)
}
if string(actual) != TimeZonesSDPExpected {
t.Errorf("error:\n\nEXPECTED:\n%v\nACTUAL:\n%v", TimeZonesSDPExpected, actual)
}
}
, z= is never appeared. I'm not very sure what was intended in this test originally.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So looking quickly through the rfc it looks liker= in section 5.10 has to do with time repeating. I inplemented this stuff almost a year ago so I really don't remember. My vote is to not touch this in this PR if it is not durectly broken or breaks something specific for your usecase. It looks like this PR is related only to CRLF termination so I would keep it this way. Maybe separate this fix into a different PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I touched this because I wanted to have a test case that ends with TimeZones and extra CRLF to cover s13's EOF handling.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add another const for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted TimeZonesSDP and added TimeZonesSDP2 for now.

Allow single '\n' as a record termination since RFC 4566 says:
> parsers SHOULD be tolerant and also accept records terminated with
> a single newline character.

Allow to have empty lines.
Other SDP parsers (e.g. one in VLC media player) allow empty lines.
@at-wat at-wat force-pushed the relax-record-termination-char-spec branch from 99a7e4d to 0bffc66 Compare March 26, 2020 23:59
@at-wat
Copy link
Member Author

at-wat commented Mar 27, 2020

@trivigy reverted const TimeZonesSDP. Please take another look.

Copy link
Member

@trivigy trivigy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@at-wat at-wat merged commit 99a4a12 into master Mar 27, 2020
@at-wat at-wat deleted the relax-record-termination-char-spec branch March 27, 2020 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sdp file parsing failed
2 participants