2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-16 17:45:09 +00:00
Commit Graph

70 Commits

Author SHA1 Message Date
m-holger
1b89e7684e Remove redundant template toO in JSON 2023-02-04 14:06:26 +00:00
m-holger
98d9ae51fc Integrate JSONParser::decode_string into getToken 2023-02-04 14:06:26 +00:00
m-holger
320245e0d1 In JSONParser::getToken decode escaped chars inside state ls_backslash
(except '\\' and '\uXXXX')
2023-02-04 14:06:26 +00:00
m-holger
cee746fc15 In JSONParser::getToken avoid copying '"' characters in strings 2023-02-04 14:06:26 +00:00
m-holger
a9a0667904 Make JSONParser::getToken responsible for decoding strings 2023-02-04 14:06:26 +00:00
m-holger
126dd31cad In JSONParser combine stacks 2023-02-04 13:53:23 +00:00
m-holger
6748bd33f7 In JSONParser::handleToken remove next_state 2023-02-04 13:53:23 +00:00
m-holger
29093a167b In JSONParser::handleToken refactor container creation 2023-02-04 13:53:23 +00:00
m-holger
a39043f65e In JSONParser::handleToken avoid creating JSON objects for dictionary keys 2023-02-04 13:53:23 +00:00
m-holger
f2e46c20b6 In JSONParser::handleToken move remaining validations into second switch statement 2023-02-04 13:53:23 +00:00
m-holger
0de032bcdd In JSONParser::handleToken simplify setting of start and end 2023-02-04 13:53:22 +00:00
m-holger
77ceebd6c9 In JSONParser::handleToken move processing for ls_end_array and ls_end_dict into switch statement 2023-02-04 13:53:22 +00:00
m-holger
a7338ab15a In JSONParser::handleToken move processing for ls_colon and ls_comma into switch statement 2023-02-04 13:53:22 +00:00
m-holger
4dba3c95dd In JSONParser::handleToken move validation for ls_colon etc into switch statement 2023-02-04 13:53:22 +00:00
m-holger
6f94a3a89a In JSONParser::handleToken move string decoding into switch statement 2023-02-04 13:53:22 +00:00
m-holger
fcc123a62a Avoid copying delimiters in JSONParser::getToken 2023-02-04 13:53:22 +00:00
m-holger
bb89a60320 Add data member JSONParser::token_start 2023-02-04 13:52:55 +00:00
m-holger
39dfd305c8 In JSONParser add lexer states for delimiters 2023-02-04 13:44:39 +00:00
m-holger
1e0ab79aec Remove redundant JSONParser::before_point etc 2023-02-01 14:19:08 +00:00
m-holger
83f972ceda Refactor end of input handling in JSONParser 2023-02-01 14:18:57 +00:00
m-holger
8fd6e1c5b2 Refactor handling of ls_number in JSONParser::getToken
Reflect that the ls_number case only handles the digits after an 'e'.

Also, change state to ls_number for all 'ready' numbers.
2023-02-01 14:18:39 +00:00
m-holger
6ea543e6c7 In JSONParser add lex_state ls_number_e_sign 2023-02-01 14:12:32 +00:00
m-holger
04333bbc20 In JSONParser add lex_state ls_number_e
Also, allow 'E' as alternative to 'e'.
2023-02-01 14:09:39 +00:00
m-holger
972ebca505 In JSONParser add lex_state ls_number_after_point 2023-02-01 14:01:57 +00:00
m-holger
cdd1f0a9f6 In JSONParser add lex_state ls_number_point
Also. remove '.' as  starting char in lsTop.
2023-02-01 14:01:57 +00:00
m-holger
bfda62aeeb In JSONParser add lex_state ls_number_before_point 2023-02-01 14:01:57 +00:00
m-holger
08e768909d In JSONParser add lex_state ls_number_leading_zero 2023-02-01 14:01:57 +00:00
m-holger
cba1c352e3 In JSONParser add lex_state ls_number_minus 2023-02-01 14:01:57 +00:00
m-holger
b6b4d3b299 Add new method JSONParser::numberError 2023-02-01 14:01:57 +00:00
m-holger
1787d85096 Refactor JSON::addDictionaryMember 2023-01-28 14:49:37 -05:00
m-holger
dce43d4f7f Refactor JSON::JSON_string::write 2023-01-28 14:49:32 -05:00
m-holger
4c914aee96 Refactor JSON::writeDictionaryKey 2023-01-28 14:49:32 -05:00
m-holger
3dde66ddcd Refactor JSON::writeNext 2023-01-28 14:49:32 -05:00
m-holger
dfa7d414f5 Refactor JSON::writeClose 2023-01-28 14:49:32 -05:00
m-holger
2e6869483b Replace calls to QUtil::int_to_string with std::to_string 2022-09-21 15:57:14 -04:00
m-holger
7c6901bce5 Code tidy: remove redundant calls to smart_ptrs get() method 2022-08-07 10:33:25 +01:00
Jay Berkenbilt
0e3d4cdc97 Fix/clarify meaning of depth parameter to json write methods 2022-07-31 10:32:55 -04:00
Jay Berkenbilt
4feb10fdaf
Merge pull request #734 from m-holger/nullptr
Code tidy : replace 0 with nullptr or true
2022-07-31 08:33:45 -04:00
m-holger
073808aa50 Code tidy : replace 0 with nullptr or true 2022-07-26 13:40:13 +01:00
Jay Berkenbilt
4674c04cb8 JSON schema: support multi-element array validation 2022-07-24 16:44:51 -04:00
Jay Berkenbilt
f8d1ab9462 JSON schema -- accept single item in place of array
When the schema wants a variable-length array, allow a single item as
well as allowing an array.
2022-07-24 16:17:03 -04:00
Jay Berkenbilt
c56a9ca7f6 JSON: Fix large file support 2022-05-21 09:43:45 -04:00
Jay Berkenbilt
3eb77a7004 JSON: detect duplicate dictionary keys while parsing 2022-05-20 10:13:15 -04:00
Jay Berkenbilt
6c7326b290 JSON fix: correctly parse UTF-16 surrogate pairs 2022-05-20 09:16:25 -04:00
Jay Berkenbilt
4c7cfd5cbc JSON reactor: improve handling of nested containers
Call the parent container's item method before calling the child
item's start method so we can easily know the current nesting level
when nested items are added.
2022-05-14 17:35:06 -04:00
Jay Berkenbilt
948de60990 Objects json: write incrementally and in numeric order
The following script was used to adjust test data:

----------
#!/usr/bin/env python3
import json
import sys
import re

def json_dumps(data):
    return json.dumps(data, ensure_ascii=False,
                      indent=2, separators=(',', ': '))

for filename in sys.argv[1:]:
    with open(filename, 'r') as f:
        data = json.loads(f.read())
    if 'objects' not in data:
        continue
    trailer = None
    to_sort = []
    for k, v in data['objects'].items():
        if k == 'trailer':
            trailer = v
        else:
            m = re.match(r'^(\d+) \d+ R', k)
            if m:
                to_sort.append([int(m.group(1)), k, v])
    newobjects = {x[1]: x[2] for x in sorted(to_sort)}
    if trailer is not None:
        newobjects['trailer'] = trailer
    data['objects'] = newobjects
print(json_dumps(data))
----------
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
a3c9980395 Add next to Pl_String and fix comments 2022-05-07 08:26:31 -04:00
Jay Berkenbilt
0500d4347a JSON: add blob type that generates base64-encoded binary data 2022-05-06 19:14:52 -04:00
Jay Berkenbilt
05fda4afa2 Change JSON parser to parse from an InputSource 2022-05-04 12:07:11 -04:00
Jay Berkenbilt
e259635986 JSON: add write methods and implement unparse() in terms of those 2022-05-04 12:07:11 -04:00