Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement and use (text|binary)_to_json #7232

Merged
merged 4 commits into from
Jan 16, 2023

Conversation

ThomasWaldmann
Copy link
Member

@ThomasWaldmann ThomasWaldmann commented Dec 28, 2022

binary bytes:

- json_key = <key>_b64
- json_value == base64(value)

text (potentially with surrogate escapes):

- json_key1 = <key>
- json_value1 = value_text (s-e replaced by ?)
- json_key2 = <key>_b64
- json_value2 = base64(value_binary)

json_key2/_value2 is only present if value_text required replacement of surrogate escapes (and thus does not represent the original value, but just an approximation).
value_binary then gives the original bytes value (e.g. a non-utf8 bytes sequence).

@codecov-commenter
Copy link

codecov-commenter commented Dec 29, 2022

Codecov Report

Merging #7232 (491f898) into master (ca1f128) will increase coverage by 0.01%.
The diff coverage is 97.43%.

@@            Coverage Diff             @@
##           master    #7232      +/-   ##
==========================================
+ Coverage   83.49%   83.51%   +0.01%     
==========================================
  Files          67       67              
  Lines       11551    11571      +20     
  Branches     2095     2096       +1     
==========================================
+ Hits         9644     9663      +19     
  Misses       1355     1355              
- Partials      552      553       +1     
Impacted Files Coverage Δ
src/borg/archive.py 83.02% <66.66%> (-0.06%) ⬇️
src/borg/archiver/__init__.py 86.13% <100.00%> (+0.09%) ⬆️
src/borg/cache.py 85.58% <100.00%> (ø)
src/borg/helpers/__init__.py 100.00% <100.00%> (ø)
src/borg/helpers/parseformat.py 89.33% <100.00%> (+0.27%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@ThomasWaldmann ThomasWaldmann changed the title implement text_to_json / binary_to_json, see #6151 implement and use (text|binary)_to_json Dec 29, 2022
binary bytes:
- json_key = <key>_b64
- json_value == base64(value)

text (potentially with surrogate escapes):
- json_key1 = <key>
- json_value1 = value_text (s-e replaced by ?)
- json_key2 = <key>_b64
- json_value2 = base64(value_binary)

json_key2/_value2 is only present if value_text required
replacement of surrogate escapes (and thus does not represent
the original value, but just an approximation).
value_binary then gives the original bytes value (e.g. a
non-utf8 bytes sequence).
item: path, source, user, group

for non-unicode stuff borg 1.2 had "bpath".

now we have:
path - unicode approximation (invalid stuff replaced by ?)
path_b64 - base64(path_bytes)  # only if needed

source has the same issue as path and is now covered also.

user and group are usually unicode or even pure ASCII,
but we rather are cautious and cover them also.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants