Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ dev
- Invalid RST_STREAM frame bodies now raise ``InvalidFramError``, not
``ValueError``. Note that ``InvalidFrameError`` is a ``ValueError`` subclass.

**Bugfixes**

- The change in ``3.1.0`` that ensured that ``InvalidFrameError`` would be
thrown did not affect certain invalid values in ALT_SVC frames. This has been
fixed: ``ValueError`` will no longer be thrown from invalid ALT_SVC bodies.

3.1.1 (2016-01-18)
------------------

Expand Down
2 changes: 1 addition & 1 deletion hyperframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def parse_body(self, data):
self.host = data[pos:pos+host_length].tobytes()
pos += host_length
self.parse_origin(data[pos:])
except struct.error:
except (struct.error, ValueError):
raise InvalidFrameError("Invalid ALTSVC frame body.")


Expand Down
9 changes: 9 additions & 0 deletions test/test_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,11 @@ class TestAltSvcFrame(object):
b'\x00\x00\x00\x1D\x00\x50\x00\x02'
b'h2\x0Agoogle.com'
)
payload_with_bad_origin = (
b'\x00\x00\x2B\x0A\x00\x00\x00\x00\x00'
b'\x00\x00\x00\x1D\x00\x50\x00\x02'
b'h2\x0Agoogle.comyahoo.com:8080'
)

def test_altsvc_frame_flags(self):
f = AltSvcFrame()
Expand Down Expand Up @@ -689,6 +694,10 @@ def test_short_altsvc_frame_errors(self):
with pytest.raises(InvalidFrameError):
decode_frame(self.payload_without_origin[:12])

def test_altsvc_with_bad_origin_fails(self):
with pytest.raises(InvalidFrameError):
decode_frame(self.payload_with_bad_origin)


class TestBlockedFrame(object):
def test_blocked_has_no_flags(self):
Expand Down