hypothesis / hypothesis/h

Badge endpoint return different results if the encoded URL has a 'https' protocol

Open
#6,472 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
3.2k
Forks
459
Avg merge
27d 1h
Merged PRs (30d)
1

Description

Making a request to the `/api/badge` endpoint return different result when the requested URL is (1) encoded and (2) has different protocol.

### Steps to reproduce
1. `curl 'https://hypothes.is/api/badge?uri=http%3A%2F%2Fexample.com%2F'`
2. `curl 'https://hypothes.is/api/badge?uri=https%3A%2F%2Fexample.com%2F'`

### Expected behaviour
It is expected that request from 1 returns the same results as from 2.

### Actual behaviour
The results from 1 and 2 are different.

### Additional details
This doesn't happens when the URL is decoded:

```
% curl 'https://hypothes.is/api/badge?uri=https://example.com'
{"total": 95}

% curl 'https://hypothes.is/api/badge?uri=http://example.com'
{"total": 95}
```
### Impact

The browser extension encodes the URL when using the badge API endpoint, hence it shows a different badge number when accessing example.com via `http` or `https`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.