Repository navigation
Conversation
The --warc-cdx writer had its own JSON escaper, which copied non-ASCII bytes verbatim. A 302 with "Location: /dest\xe9" therefore wrote a CDXJ line whose JSON is not UTF-8, and json.loads() refuses it. Move the --changes escaper, which already turns invalid UTF-8 into U+FFFD, to htscharset.c as hts_json_string(), and make cdx_json_str() a wrapper over it. It cannot go to htsescape.c: htsserver links that file on its own and hts_isStringUTF8() is not exported. The WARC-Target-URI header still carries the raw bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Xavier Roche <roche@httrack.com>
The JSON object was escaped, but the SURT key in front of it still carried the raw bytes, so a whole-line UTF-8 decode of the .cdx failed. The self-test now decodes the whole line, and warc-surt pins the key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Xavier Roche <roche@httrack.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
--warc-cdxindex now uses the JSON escaper of--changes, so a URL byte that is not valid UTF-8 becomes�in the JSON. The SURT key in front of the JSON percent-encodes such bytes, so every line decodes as UTF-8. The sharedhts_json_string()is inhtscharset.cand not inhtsescape.c, becausehtsserverlinkshtsescape.citself and cannot reach the unexportedhts_isStringUTF8().A crawl that follows a 302 to
Location: /dest\xe9wrote one CDXJ line that Python cannot decode on master, and none on this branch. The self-testswarc-cdx-utf8andwarc-surtfail when the old escaper or the raw key is put back.