Skip to content

Does not handle utf8 #11

@anentropic

Description

@anentropic

Default encoding for JSON is UTF8 https://datatracker.ietf.org/doc/html/rfc7159#section-8.1

If you pass a file containing unicode chars to dollar_ref it will fail:

/usr/local/lib/python3.6/dist-packages/dollar_ref/__init__.py:166: in resolve_file
--
51 | file_data = read_file(path)
52 | /usr/local/lib/python3.6/dist-packages/dollar_ref/__init__.py:197: in read_file
53 | raw = file.read()
54 | /usr/lib/python3.6/encodings/ascii.py:26: in decode
55 | return codecs.ascii_decode(input, self.errors)[0]
56 | E   UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 30017: ordinal not in range(128)

I guess the call to open needs encoding="utf8" here: https://github.com/bagrat/dollar-ref/blob/master/dollar_ref/__init__.py#L196

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions