Opened 3 months ago

Closed 3 months ago

Last modified 3 months ago

#31126 closed defect (fixed)

Query.parse returns spurious keys (originating from Object.prototype)

Reported by: dcf Owned by: dcf
Priority: Medium Milestone:
Component: Circumvention/Snowflake Version:
Severity: Minor Keywords:
Cc: arlolra, cohosh, phw, dcf Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

For example, these test cases would fail:

describe 'query string', ->
  it 'should parse correctly', ->
    expect ("toString" in (Query.parse ''))
      .toBe(false)
    expect ((Query.parse '')["hasOwnProperty"])
      .toBeUndefined()

I'm tempted to replace all this with new URL and URLSearchParams.

Child Tickets

Change History (6)

comment:1 Changed 3 months ago by arlolra

Sure, or use a Map

comment:2 Changed 3 months ago by dcf

Status: assignedneeds_review

Here's a branch for review. It deletes Query.parse and replaces Query.parse(location.search.substr(1)) with new URLSearchParams(location.search). Then in a second commit, I converted the single call to Query.buildString(params) to new URLSearchParams(params).toString(), and removed the now-unused Query global.

https://gitweb.torproject.org/user/dcf/snowflake.git/log/?h=bug31126&id=e87ec6585801eb704ccabb783a56bc9a29ea2c7b
https://gitweb.torproject.org/user/dcf/snowflake.git/diff/?h=bug31126&id=e87ec6585801eb704ccabb783a56bc9a29ea2c7b&id2=76b81bcf77be01565365833ade805397ed093dc9

comment:3 Changed 3 months ago by arlolra

Status: needs_reviewmerge_ready

lgtm

comment:4 Changed 3 months ago by dcf

Resolution: fixed
Status: merge_readyclosed

comment:5 Changed 3 months ago by cohosh

Looks like there might be a broken test here: https://travis-ci.com/cohosh/snowflake/builds/120769742#L915

comment:6 in reply to:  5 Changed 3 months ago by dcf

Replying to cohosh:

Looks like there might be a broken test here: https://travis-ci.com/cohosh/snowflake/builds/120769742#L915

Oops, you're right. It's actually a problem with #31203.

Note: See TracTickets for help on using tickets.