[tor-bugs] #31203 [Circumvention/Snowflake]: Fix Parse.byteCount in the case of unknown units

Tor Bug Tracker & Wiki blackhole at torproject.org
Fri Jul 19 00:13:24 UTC 2019


#31203: Fix Parse.byteCount in the case of unknown units
-----------------------------------------+----------------------
     Reporter:  dcf                      |      Owner:  dcf
         Type:  defect                   |     Status:  assigned
     Priority:  Medium                   |  Milestone:
    Component:  Circumvention/Snowflake  |    Version:
     Severity:  Normal                   |   Keywords:
Actual Points:                           |  Parent ID:
       Points:                           |   Reviewer:
      Sponsor:                           |
-----------------------------------------+----------------------
 `Parse.byteCount` is supposed to parse numbers followed by an optional
 units suffix, like `"1500"` or `"1.5M"`. It behaves incorrectly in the
 case of an unrecognized suffix (`"1.5X"`), returning `NaN` instead of
 `null`.

 The first part of the patch adds tests for `Parse.byteCount` and
 `Params.getByteCount`, which fail:
 {{{
 1) Parse byte count returns null for bad inputs
   Message:
     Expected NaN to be null.
   Stack:
     Error: Expected NaN to be null.
         at Object.<anonymous>
 (snowflake/proxy/test/bundle.spec.js:1849:37)
   ...
 }}}

 The second part of the patch fixes `Parse.byteCount` so it doesn't fail.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/31203>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list