From 7adccd95b2be0f0832c71258ccbf20a3ad9663ce Mon Sep 17 00:00:00 2001 From: Bob Ippolito Date: Fri, 16 Jan 2015 15:52:50 -0800 Subject: [PATCH] Fix range parsing regression introduced in #147 --- CHANGES.md | 5 +++++ src/mochiweb.app.src | 2 +- src/mochiweb_http.erl | 8 +++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b1341822..b591a434 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +Version 2.11.2 released 2015-01-16 + +* Fix regression introduced in #147 + https://github.com/mochi/mochiweb/pull/147 + Version 2.11.1 released 2015-01-16 * Accept range end position which exceededs the resource size diff --git a/src/mochiweb.app.src b/src/mochiweb.app.src index bb4f4afa..97fc90d3 100644 --- a/src/mochiweb.app.src +++ b/src/mochiweb.app.src @@ -1,7 +1,7 @@ %% This is generated from src/mochiweb.app.src {application, mochiweb, [{description, "MochiMedia Web Server"}, - {vsn, "2.11.1"}, + {vsn, "2.11.2"}, {modules, []}, {registered, []}, {env, []}, diff --git a/src/mochiweb_http.erl b/src/mochiweb_http.erl index 271531b5..1ea1f153 100644 --- a/src/mochiweb_http.erl +++ b/src/mochiweb_http.erl @@ -184,11 +184,9 @@ range_skip_length(Spec, Size) -> {R, Size - R}; {_OutOfRange, none} -> invalid_range; - {Start, End} when 0 =< Start, Start < Size, Start =< End -> - {Start, End - Start + 1}; - {Start, End} when 0 =< Start, Start =< End, End >= Size -> - {Start, Size - Start}; - {_OutOfRange, _End} -> + {Start, End} when Start >= 0, Start < Size, Start =< End -> + {Start, erlang:min(End + 1, Size) - Start}; + {_InvalidStart, _InvalidEnd} -> invalid_range end.