muhammara 2.0.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -1
- package/README.md +2 -2
- package/node_modules/@mapbox/node-pre-gyp/CHANGELOG.md +10 -0
- package/node_modules/@mapbox/node-pre-gyp/lib/util/abi_crosswalk.json +16 -0
- package/node_modules/@mapbox/node-pre-gyp/lib/util/versioning.js +1 -1
- package/node_modules/@mapbox/node-pre-gyp/package.json +10 -11
- package/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/ansi-regex/index.js +4 -4
- package/node_modules/ansi-regex/package.json +17 -15
- package/node_modules/ansi-regex/readme.md +35 -3
- package/node_modules/brace-expansion/package.json +2 -1
- package/node_modules/debug/LICENSE +10 -9
- package/node_modules/debug/README.md +27 -1
- package/node_modules/debug/package.json +15 -15
- package/node_modules/debug/src/common.js +2 -2
- package/node_modules/detect-libc/README.md +124 -42
- package/node_modules/detect-libc/index.d.ts +11 -0
- package/node_modules/detect-libc/lib/detect-libc.js +166 -80
- package/node_modules/detect-libc/lib/process.js +16 -0
- package/node_modules/detect-libc/package.json +20 -19
- package/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/emoji-regex/README.md +73 -0
- package/node_modules/emoji-regex/es2015/index.js +6 -0
- package/node_modules/emoji-regex/es2015/text.js +6 -0
- package/node_modules/emoji-regex/index.d.ts +23 -0
- package/node_modules/emoji-regex/index.js +6 -0
- package/node_modules/emoji-regex/package.json +77 -0
- package/node_modules/emoji-regex/text.js +6 -0
- package/node_modules/gauge/package.json +7 -7
- package/node_modules/https-proxy-agent/dist/agent.js +2 -5
- package/node_modules/https-proxy-agent/dist/agent.js.map +1 -1
- package/node_modules/https-proxy-agent/package.json +5 -5
- package/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
- package/node_modules/is-fullwidth-code-point/index.js +25 -21
- package/node_modules/is-fullwidth-code-point/license +4 -16
- package/node_modules/is-fullwidth-code-point/package.json +18 -24
- package/node_modules/is-fullwidth-code-point/readme.md +6 -6
- package/node_modules/minimatch/README.md +22 -1
- package/node_modules/minimatch/minimatch.js +93 -69
- package/node_modules/minimatch/package.json +11 -10
- package/node_modules/minipass/index.js +6 -1
- package/node_modules/minipass/package.json +5 -5
- package/node_modules/node-fetch/lib/index.es.js +29 -3
- package/node_modules/node-fetch/lib/index.js +29 -3
- package/node_modules/node-fetch/lib/index.mjs +29 -3
- package/node_modules/node-fetch/package.json +18 -10
- package/node_modules/semver/README.md +3 -1
- package/node_modules/semver/bin/semver.js +19 -9
- package/node_modules/semver/classes/comparator.js +3 -2
- package/node_modules/semver/classes/index.js +1 -1
- package/node_modules/semver/classes/range.js +31 -22
- package/node_modules/semver/classes/semver.js +1 -1
- package/node_modules/semver/functions/cmp.js +8 -4
- package/node_modules/semver/functions/coerce.js +3 -2
- package/node_modules/semver/functions/inc.js +4 -1
- package/node_modules/semver/functions/parse.js +1 -1
- package/node_modules/semver/internal/constants.js +2 -2
- package/node_modules/semver/internal/identifiers.js +1 -1
- package/node_modules/semver/internal/parse-options.js +3 -3
- package/node_modules/semver/internal/re.js +3 -3
- package/node_modules/semver/package.json +46 -13
- package/node_modules/semver/ranges/min-version.js +2 -1
- package/node_modules/semver/ranges/outside.js +1 -1
- package/node_modules/semver/ranges/simplify.js +15 -12
- package/node_modules/semver/ranges/subset.js +53 -31
- package/node_modules/signal-exit/index.js +34 -10
- package/node_modules/signal-exit/package.json +11 -9
- package/node_modules/string-width/index.d.ts +29 -0
- package/node_modules/string-width/index.js +16 -5
- package/node_modules/string-width/package.json +20 -20
- package/node_modules/string-width/readme.md +15 -7
- package/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/strip-ansi/index.js +1 -1
- package/node_modules/strip-ansi/package.json +19 -17
- package/node_modules/strip-ansi/readme.md +12 -5
- package/package.json +1 -1
- package/src/DocumentCopyingContextDriver.cpp +6 -6
- package/src/deps/PDFWriter/CMakeLists.txt +8 -0
- package/src/deps/PDFWriter/DecryptionHelper.cpp +10 -8
- package/src/deps/PDFWriter/Deletable.h +46 -0
- package/src/deps/PDFWriter/DocumentContext.h +3 -3
- package/src/deps/PDFWriter/IDeletable.h +6 -0
- package/src/deps/PDFWriter/InputLZWDecodeStream.cpp +208 -0
- package/src/deps/PDFWriter/InputLZWDecodeStream.h +77 -0
- package/src/deps/PDFWriter/InputStreamSkipperStream.cpp +1 -1
- package/src/deps/PDFWriter/JPEGImageHandler.h +2 -2
- package/src/deps/PDFWriter/ObjectsContext.cpp +5 -0
- package/src/deps/PDFWriter/ObjectsContext.h +1 -0
- package/src/deps/PDFWriter/PDFDocumentHandler.cpp +19 -3
- package/src/deps/PDFWriter/PDFObject.cpp +13 -11
- package/src/deps/PDFWriter/PDFObject.h +7 -5
- package/src/deps/PDFWriter/PDFObjectParser.cpp +8 -0
- package/src/deps/PDFWriter/PDFObjectParser.h +6 -0
- package/src/deps/PDFWriter/PDFParser.cpp +25 -13
- package/src/deps/PDFWriter/PDFParserTokenizer.cpp +25 -24
- package/src/deps/PDFWriter/PDFParserTokenizer.h +1 -0
- package/src/deps/PDFWriter/PDFWriter.h +2 -2
- package/src/deps/PDFWriter/binding.gyp +2 -0
- package/node_modules/detect-libc/.npmignore +0 -7
- package/node_modules/detect-libc/bin/detect-libc.js +0 -18
- package/node_modules/semver/CHANGELOG.md +0 -111
- package/src/deps/PDFWriter/InputPredictorPNGAverageStream.cpp +0 -120
- package/src/deps/PDFWriter/InputPredictorPNGAverageStream.h +0 -49
- package/src/deps/PDFWriter/InputPredictorPNGNoneStream.cpp +0 -109
- package/src/deps/PDFWriter/InputPredictorPNGNoneStream.h +0 -47
- package/src/deps/PDFWriter/InputPredictorPNGPaethStream.cpp +0 -136
- package/src/deps/PDFWriter/InputPredictorPNGPaethStream.h +0 -51
- package/src/deps/PDFWriter/InputPredictorPNGSubStream.cpp +0 -113
- package/src/deps/PDFWriter/InputPredictorPNGSubStream.h +0 -47
- package/src/deps/PDFWriter/InputPredictorPNGUpStream.cpp +0 -120
- package/src/deps/PDFWriter/InputPredictorPNGUpStream.h +0 -49
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
*/
|
|
21
21
|
#include "PDFObject.h"
|
|
22
|
+
#include "IDeletable.h"
|
|
22
23
|
|
|
23
24
|
const char* PDFObject::scPDFObjectTypeLabel(int index)
|
|
24
25
|
{
|
|
@@ -53,9 +54,9 @@ PDFObject::PDFObject(int inType)
|
|
|
53
54
|
|
|
54
55
|
PDFObject::~PDFObject(void)
|
|
55
56
|
{
|
|
56
|
-
|
|
57
|
+
StringToIDeletable::iterator it = mMetadata.begin();
|
|
57
58
|
for (; it != mMetadata.end(); ++it) {
|
|
58
|
-
|
|
59
|
+
it->second->DeleteMe();
|
|
59
60
|
}
|
|
60
61
|
mMetadata.clear();
|
|
61
62
|
}
|
|
@@ -65,15 +66,15 @@ PDFObject::EPDFObjectType PDFObject::GetType()
|
|
|
65
66
|
return mType;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
void PDFObject::SetMetadata(const std::string& inKey,
|
|
69
|
+
void PDFObject::SetMetadata(const std::string& inKey, IDeletable* inValue) {
|
|
69
70
|
// delete old metadata
|
|
70
71
|
DeleteMetadata(inKey);
|
|
71
72
|
|
|
72
|
-
mMetadata.insert(
|
|
73
|
+
mMetadata.insert(StringToIDeletable::value_type(inKey, inValue));
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
IDeletable* PDFObject::GetMetadata(const std::string& inKey) {
|
|
77
|
+
StringToIDeletable::iterator it = mMetadata.find(inKey);
|
|
77
78
|
|
|
78
79
|
if (it == mMetadata.end())
|
|
79
80
|
return NULL;
|
|
@@ -81,19 +82,20 @@ void* PDFObject::GetMetadata(const std::string& inKey) {
|
|
|
81
82
|
return it->second;
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
IDeletable* PDFObject::DetachMetadata(const std::string& inKey) {
|
|
86
|
+
StringToIDeletable::iterator it = mMetadata.find(inKey);
|
|
86
87
|
|
|
87
88
|
if (it == mMetadata.end())
|
|
88
89
|
return NULL;
|
|
89
90
|
else {
|
|
90
|
-
|
|
91
|
+
IDeletable* result = it->second;
|
|
91
92
|
mMetadata.erase(it);
|
|
92
93
|
return result;
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
void PDFObject::DeleteMetadata(const std::string& inKey) {
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
IDeletable* result = DetachMetadata(inKey);
|
|
99
|
+
if(result)
|
|
100
|
+
result->DeleteMe();
|
|
99
101
|
}
|
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
#include <string>
|
|
26
26
|
#include <map>
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
class IDeletable;
|
|
29
|
+
|
|
30
|
+
typedef std::map<std::string, IDeletable*> StringToIDeletable;
|
|
29
31
|
|
|
30
32
|
class PDFObject : public RefCountObject
|
|
31
33
|
{
|
|
@@ -58,14 +60,14 @@ public:
|
|
|
58
60
|
/*
|
|
59
61
|
metadata will automatically be deleted when object is released
|
|
60
62
|
*/
|
|
61
|
-
void SetMetadata(const std::string& inKey,
|
|
62
|
-
|
|
63
|
+
void SetMetadata(const std::string& inKey,IDeletable* inValue); // will automatically delete old data in the same key
|
|
64
|
+
IDeletable* GetMetadata(const std::string& inKey);
|
|
63
65
|
// Detach will only remove the pointer from metadata map, Delete will also delete the inValue pointer
|
|
64
|
-
|
|
66
|
+
IDeletable* DetachMetadata(const std::string& inKey);
|
|
65
67
|
void DeleteMetadata(const std::string& inKey);
|
|
66
68
|
|
|
67
69
|
|
|
68
70
|
private:
|
|
69
71
|
EPDFObjectType mType;
|
|
70
|
-
|
|
72
|
+
StringToIDeletable mMetadata;
|
|
71
73
|
};
|
|
@@ -706,4 +706,12 @@ void PDFObjectParser::SetDecryptionHelper(DecryptionHelper* inDecryptionHelper)
|
|
|
706
706
|
void PDFObjectParser::SetParserExtender(IPDFParserExtender* inParserExtender)
|
|
707
707
|
{
|
|
708
708
|
mParserExtender = inParserExtender;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
IByteReader* PDFObjectParser::StartExternalRead() {
|
|
712
|
+
return mStream;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
void PDFObjectParser::EndExternalRead() {
|
|
716
|
+
ResetReadState();
|
|
709
717
|
}
|
|
@@ -49,6 +49,7 @@ public:
|
|
|
49
49
|
// Assign the stream to read from (does not take ownership of the stream, unless told so)
|
|
50
50
|
void SetReadStream(IByteReader* inSourceStream,IReadPositionProvider* inCurrentPositionProvider,bool inOwnsStream=false);
|
|
51
51
|
|
|
52
|
+
// the important bit - get next object in content stream
|
|
52
53
|
PDFObject* ParseNewObject();
|
|
53
54
|
|
|
54
55
|
// calls this when changing underlying stream position
|
|
@@ -64,6 +65,11 @@ public:
|
|
|
64
65
|
// helper method for others who need to parse encoded pdf data
|
|
65
66
|
std::string DecodeHexString(const std::string inStringToDecode);
|
|
66
67
|
|
|
68
|
+
// External reading. use to temporarily get access to the internal stream, instead of reading objects with ParseNewObject.
|
|
69
|
+
// when done mark with FinishExternalReading to commence reading
|
|
70
|
+
IByteReader* StartExternalRead();
|
|
71
|
+
void EndExternalRead();
|
|
72
|
+
|
|
67
73
|
private:
|
|
68
74
|
PDFParserTokenizer mTokenizer;
|
|
69
75
|
StringList mTokenBuffer;
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
#include "PDFStreamInput.h"
|
|
37
37
|
#include "InputLimitedStream.h"
|
|
38
38
|
#include "InputFlateDecodeStream.h"
|
|
39
|
+
#include "InputLZWDecodeStream.h"
|
|
39
40
|
#include "InputStreamSkipperStream.h"
|
|
40
41
|
#include "InputPredictorPNGOptimumStream.h"
|
|
41
42
|
#include "InputPredictorTIFFSubStream.h"
|
|
@@ -1925,27 +1926,39 @@ EStatusCodeAndIByteReader PDFParser::CreateFilterForStream(IByteReader* inStream
|
|
|
1925
1926
|
do
|
|
1926
1927
|
{
|
|
1927
1928
|
|
|
1928
|
-
if(inFilterName->GetValue() == "FlateDecode")
|
|
1929
|
+
if(inFilterName->GetValue() == "FlateDecode" || inFilterName->GetValue() == "LZWDecode")
|
|
1929
1930
|
{
|
|
1930
|
-
|
|
1931
|
-
flateStream = new InputFlateDecodeStream(NULL); // assigning null, so later delete, if failure occurs won't delete the input stream
|
|
1932
|
-
result = flateStream;
|
|
1933
|
-
|
|
1934
|
-
// check for predictor n' such
|
|
1935
|
-
if(!inDecodeParams)
|
|
1931
|
+
if (inFilterName->GetValue() == "FlateDecode")
|
|
1936
1932
|
{
|
|
1937
|
-
|
|
1933
|
+
InputFlateDecodeStream* flateStream;
|
|
1934
|
+
flateStream = new InputFlateDecodeStream(NULL); // assigning null, so later delete, if failure occurs won't delete the input stream
|
|
1938
1935
|
flateStream->Assign(inStream);
|
|
1939
|
-
|
|
1936
|
+
result = flateStream;
|
|
1937
|
+
}
|
|
1938
|
+
else if (inFilterName->GetValue() == "LZWDecode")
|
|
1939
|
+
{
|
|
1940
|
+
InputLZWDecodeStream* lzwStream;
|
|
1941
|
+
int early = 1;
|
|
1942
|
+
if (inDecodeParams)
|
|
1943
|
+
{
|
|
1944
|
+
PDFObjectCastPtr<PDFInteger> earlyObj(QueryDictionaryObject(inDecodeParams, "EarlyChange"));
|
|
1945
|
+
early = earlyObj->GetValue();
|
|
1946
|
+
}
|
|
1947
|
+
lzwStream = new InputLZWDecodeStream(early);
|
|
1948
|
+
lzwStream->Assign(inStream);
|
|
1949
|
+
result = lzwStream;
|
|
1940
1950
|
}
|
|
1941
1951
|
|
|
1952
|
+
// check for predictor n' such
|
|
1953
|
+
if (!inDecodeParams)
|
|
1954
|
+
// no predictor, stop here
|
|
1955
|
+
break;
|
|
1956
|
+
|
|
1942
1957
|
// read predictor, and apply the relevant predictor function
|
|
1943
1958
|
PDFObjectCastPtr<PDFInteger> predictor(QueryDictionaryObject(inDecodeParams,"Predictor"));
|
|
1944
1959
|
|
|
1945
1960
|
if(!predictor || predictor->GetValue() == 1)
|
|
1946
1961
|
{
|
|
1947
|
-
// no predictor or default, stop here
|
|
1948
|
-
flateStream->Assign(inStream);
|
|
1949
1962
|
break;
|
|
1950
1963
|
}
|
|
1951
1964
|
|
|
@@ -1994,7 +2007,6 @@ EStatusCodeAndIByteReader PDFParser::CreateFilterForStream(IByteReader* inStream
|
|
|
1994
2007
|
break;
|
|
1995
2008
|
}
|
|
1996
2009
|
}
|
|
1997
|
-
flateStream->Assign(inStream);
|
|
1998
2010
|
}
|
|
1999
2011
|
else if (inFilterName->GetValue() == "ASCIIHexDecode")
|
|
2000
2012
|
{
|
|
@@ -2028,7 +2040,7 @@ EStatusCodeAndIByteReader PDFParser::CreateFilterForStream(IByteReader* inStream
|
|
|
2028
2040
|
}
|
|
2029
2041
|
else
|
|
2030
2042
|
{
|
|
2031
|
-
TRACE_LOG("PDFParser::CreateFilterForStream, supporting only flate decode and ascii 85 decode, failing");
|
|
2043
|
+
TRACE_LOG("PDFParser::CreateFilterForStream, supporting only flate decode, lzw, dct, crypt and ascii 85+hex decode, failing");
|
|
2032
2044
|
status = PDFHummus::eFailure;
|
|
2033
2045
|
break;
|
|
2034
2046
|
}
|
|
@@ -67,7 +67,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
67
67
|
Byte buffer;
|
|
68
68
|
OutputStringBufferStream tokenBuffer;
|
|
69
69
|
|
|
70
|
-
if(!
|
|
70
|
+
if(!CanGetNextByte())
|
|
71
71
|
{
|
|
72
72
|
result.first = false;
|
|
73
73
|
return result;
|
|
@@ -76,7 +76,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
76
76
|
do
|
|
77
77
|
{
|
|
78
78
|
SkipTillToken();
|
|
79
|
-
if(!
|
|
79
|
+
if(!CanGetNextByte())
|
|
80
80
|
{
|
|
81
81
|
result.first = false;
|
|
82
82
|
break;
|
|
@@ -103,11 +103,11 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
103
103
|
case '%':
|
|
104
104
|
{
|
|
105
105
|
// for a comment, the token goes on till the end of line marker [not including]
|
|
106
|
-
while(
|
|
106
|
+
while(CanGetNextByte())
|
|
107
107
|
{
|
|
108
108
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
109
109
|
{
|
|
110
|
-
result.first = !
|
|
110
|
+
result.first = !CanGetNextByte();
|
|
111
111
|
break;
|
|
112
112
|
}
|
|
113
113
|
if(0xD == buffer|| 0xA == buffer)
|
|
@@ -123,11 +123,11 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
123
123
|
// for a literal string, the token goes on until the balanced-closing right paranthesis
|
|
124
124
|
int balanceLevel = 1;
|
|
125
125
|
bool backSlashEncountered = false;
|
|
126
|
-
while(balanceLevel > 0 &&
|
|
126
|
+
while(balanceLevel > 0 && CanGetNextByte())
|
|
127
127
|
{
|
|
128
128
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
129
129
|
{
|
|
130
|
-
result.first = !
|
|
130
|
+
result.first = !CanGetNextByte();
|
|
131
131
|
break;
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -138,11 +138,11 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
138
138
|
{
|
|
139
139
|
// ignore backslash and newline. might also need to read extra
|
|
140
140
|
// for cr-ln
|
|
141
|
-
if(0xD == buffer &&
|
|
141
|
+
if(0xD == buffer && CanGetNextByte())
|
|
142
142
|
{
|
|
143
143
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
144
144
|
{
|
|
145
|
-
result.first = !
|
|
145
|
+
result.first = !CanGetNextByte();
|
|
146
146
|
break;
|
|
147
147
|
}
|
|
148
148
|
if(buffer != 0xA)
|
|
@@ -179,7 +179,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
179
179
|
// k. this might be a dictionary start marker or a hax string start. depending on whether it has a < following it or not
|
|
180
180
|
|
|
181
181
|
// Hex string, read till end of hex string marker
|
|
182
|
-
if(!
|
|
182
|
+
if(!CanGetNextByte())
|
|
183
183
|
{
|
|
184
184
|
result.second = tokenBuffer.ToString();
|
|
185
185
|
break;
|
|
@@ -187,7 +187,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
187
187
|
|
|
188
188
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
189
189
|
{
|
|
190
|
-
result.first = !
|
|
190
|
+
result.first = !CanGetNextByte();
|
|
191
191
|
break;
|
|
192
192
|
}
|
|
193
193
|
|
|
@@ -204,11 +204,11 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
204
204
|
|
|
205
205
|
tokenBuffer.Write(&buffer,1);
|
|
206
206
|
|
|
207
|
-
while(
|
|
207
|
+
while(CanGetNextByte() && buffer != '>')
|
|
208
208
|
{
|
|
209
209
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
210
210
|
{
|
|
211
|
-
result.first = !
|
|
211
|
+
result.first = !CanGetNextByte();
|
|
212
212
|
break;
|
|
213
213
|
}
|
|
214
214
|
|
|
@@ -227,7 +227,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
227
227
|
break;
|
|
228
228
|
case '>': // parse end dictionary marker as a single entity or a hex string end marker
|
|
229
229
|
{
|
|
230
|
-
if(!
|
|
230
|
+
if(!CanGetNextByte()) // this means a loose end string marker...wierd
|
|
231
231
|
{
|
|
232
232
|
result.second = tokenBuffer.ToString();
|
|
233
233
|
break;
|
|
@@ -235,7 +235,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
235
235
|
|
|
236
236
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
237
237
|
{
|
|
238
|
-
result.first = !
|
|
238
|
+
result.first = !CanGetNextByte();
|
|
239
239
|
break;
|
|
240
240
|
}
|
|
241
241
|
|
|
@@ -258,11 +258,11 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
258
258
|
|
|
259
259
|
default: // regular token. read till next breaker or whitespace
|
|
260
260
|
{
|
|
261
|
-
while(
|
|
261
|
+
while(CanGetNextByte())
|
|
262
262
|
{
|
|
263
263
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
264
264
|
{
|
|
265
|
-
result.first = !
|
|
265
|
+
result.first = !CanGetNextByte();
|
|
266
266
|
break;
|
|
267
267
|
}
|
|
268
268
|
if(IsPDFWhiteSpace(buffer))
|
|
@@ -279,7 +279,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
279
279
|
}
|
|
280
280
|
result.second = tokenBuffer.ToString();
|
|
281
281
|
|
|
282
|
-
if(result.first &&
|
|
282
|
+
if(result.first && CanGetNextByte() && scStream == result.second)
|
|
283
283
|
{
|
|
284
284
|
// k. a bit of a special case here for streams. the reading changes after the keyword "stream",
|
|
285
285
|
// essentially forcing the next content to start after either CR, CR-LF or LF. so there might be a little
|
|
@@ -288,9 +288,9 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
288
288
|
// that we should either skip one more "LF" or do nothing (based on what was parsed)
|
|
289
289
|
|
|
290
290
|
// verify that when whitespaces are finished buffer is either CR or LF, and behave accordingly
|
|
291
|
-
while(
|
|
291
|
+
while(CanGetNextByte()) {
|
|
292
292
|
if (!IsPDFWhiteSpace(buffer)) {
|
|
293
|
-
result.first = !
|
|
293
|
+
result.first = !CanGetNextByte(); // something wrong! not whitespace
|
|
294
294
|
break;
|
|
295
295
|
}
|
|
296
296
|
|
|
@@ -311,7 +311,7 @@ BoolAndString PDFParserTokenizer::GetNextToken()
|
|
|
311
311
|
} // else - some other white space
|
|
312
312
|
|
|
313
313
|
if (GetNextByteForToken(buffer) != PDFHummus::eSuccess) {
|
|
314
|
-
result.first = !
|
|
314
|
+
result.first = !CanGetNextByte(); //can't read but not eof. fail
|
|
315
315
|
break;
|
|
316
316
|
}
|
|
317
317
|
}
|
|
@@ -332,11 +332,8 @@ void PDFParserTokenizer::SkipTillToken()
|
|
|
332
332
|
{
|
|
333
333
|
Byte buffer = 0;
|
|
334
334
|
|
|
335
|
-
if(!mStream)
|
|
336
|
-
return;
|
|
337
|
-
|
|
338
335
|
// skip till hitting first non space, or segment end
|
|
339
|
-
while(
|
|
336
|
+
while(CanGetNextByte())
|
|
340
337
|
{
|
|
341
338
|
if(GetNextByteForToken(buffer) != PDFHummus::eSuccess)
|
|
342
339
|
break;
|
|
@@ -349,6 +346,10 @@ void PDFParserTokenizer::SkipTillToken()
|
|
|
349
346
|
}
|
|
350
347
|
}
|
|
351
348
|
|
|
349
|
+
bool PDFParserTokenizer::CanGetNextByte() {
|
|
350
|
+
return !!mStream && (mHasTokenBuffer || mStream->NotEnded());
|
|
351
|
+
}
|
|
352
|
+
|
|
352
353
|
EStatusCode PDFParserTokenizer::GetNextByteForToken(Byte& outByte)
|
|
353
354
|
{
|
|
354
355
|
++mStreamPositionTracker; // advance position tracker, because we are reading the next byte.
|
|
@@ -83,6 +83,7 @@ private:
|
|
|
83
83
|
|
|
84
84
|
void SkipTillToken();
|
|
85
85
|
|
|
86
|
+
bool CanGetNextByte();
|
|
86
87
|
// failure in GetNextByteForToken actually marks a true read failure, if you checked end of file before calling it...
|
|
87
88
|
PDFHummus::EStatusCode GetNextByteForToken(IOBasicTypes::Byte& outByte);
|
|
88
89
|
|
|
@@ -263,8 +263,8 @@ public:
|
|
|
263
263
|
|
|
264
264
|
// some public image info services, for users of hummus
|
|
265
265
|
DoubleAndDoublePair GetImageDimensions(const std::string& inImageFile,unsigned long inImageIndex = 0, const PDFParsingOptions& inParsingOptions = PDFParsingOptions::DefaultPDFParsingOptions());
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
DoubleAndDoublePair GetImageDimensions(IByteReaderWithPosition* inImageStream,unsigned long inImageIndex = 0, const PDFParsingOptions& inParsingOptions = PDFParsingOptions::DefaultPDFParsingOptions());
|
|
267
|
+
EHummusImageType GetImageType(const std::string& inImageFile,unsigned long inImageIndex);
|
|
268
268
|
unsigned long GetImagePagesCount(const std::string& inImageFile, const PDFParsingOptions& inOptions = PDFParsingOptions::DefaultPDFParsingOptions());
|
|
269
269
|
|
|
270
270
|
|
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
'InputFile.cpp',
|
|
74
74
|
'InputFileStream.cpp',
|
|
75
75
|
'InputFlateDecodeStream.cpp',
|
|
76
|
+
'InputLZWDecodeStream.cpp',
|
|
76
77
|
'InputLimitedStream.cpp',
|
|
77
78
|
'InputPFBDecodeStream.cpp',
|
|
78
79
|
'InputPredictorPNGOptimumStream.cpp',
|
|
@@ -239,6 +240,7 @@
|
|
|
239
240
|
'InputDCTDecodeStream.h',
|
|
240
241
|
'InputFile.h',
|
|
241
242
|
'InputFileStream.h',
|
|
243
|
+
'InputLZWDecodeStream.h',
|
|
242
244
|
'InputFlateDecodeStream.h',
|
|
243
245
|
'InputLimitedStream.h',
|
|
244
246
|
'InputPFBDecodeStream.h',
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
var spawnSync = require('child_process').spawnSync;
|
|
6
|
-
var libc = require('../');
|
|
7
|
-
|
|
8
|
-
var spawnOptions = {
|
|
9
|
-
env: process.env,
|
|
10
|
-
shell: true,
|
|
11
|
-
stdio: 'inherit'
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
if (libc.isNonGlibcLinux) {
|
|
15
|
-
spawnOptions.env.LIBC = process.env.LIBC || libc.family;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
process.exit(spawnSync(process.argv[2], process.argv.slice(3), spawnOptions).status);
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
# changes log
|
|
2
|
-
|
|
3
|
-
## 7.3.0
|
|
4
|
-
|
|
5
|
-
* Add `subset(r1, r2)` method to determine if `r1` range is entirely
|
|
6
|
-
contained by `r2` range.
|
|
7
|
-
|
|
8
|
-
## 7.2.3
|
|
9
|
-
|
|
10
|
-
* Fix handling of `includePrelease` mode where version ranges like `1.0.0 -
|
|
11
|
-
2.0.0` would include `3.0.0-pre` and not `1.0.0-pre`.
|
|
12
|
-
|
|
13
|
-
## 7.2.2
|
|
14
|
-
|
|
15
|
-
* Fix bug where `2.0.0-pre` would be included in `^1.0.0` if
|
|
16
|
-
`includePrerelease` was set to true.
|
|
17
|
-
|
|
18
|
-
## 7.2.0
|
|
19
|
-
|
|
20
|
-
* Add `simplifyRange` method to attempt to generate a more human-readable
|
|
21
|
-
range expression that is equivalent to a supplied range, for a given set
|
|
22
|
-
of versions.
|
|
23
|
-
|
|
24
|
-
## 7.1.2
|
|
25
|
-
|
|
26
|
-
* Remove fancy lazy-loading logic, as it was causing problems for webpack
|
|
27
|
-
users.
|
|
28
|
-
|
|
29
|
-
## 7.1.0
|
|
30
|
-
|
|
31
|
-
* Add `require('semver/preload')` to load the entire module without using
|
|
32
|
-
lazy getter methods.
|
|
33
|
-
|
|
34
|
-
## 7.0.0
|
|
35
|
-
|
|
36
|
-
* Refactor module into separate files for better tree-shaking
|
|
37
|
-
* Drop support for very old node versions, use const/let, `=>` functions,
|
|
38
|
-
and classes.
|
|
39
|
-
|
|
40
|
-
## 6.3.0
|
|
41
|
-
|
|
42
|
-
* Expose the token enum on the exports
|
|
43
|
-
|
|
44
|
-
## 6.2.0
|
|
45
|
-
|
|
46
|
-
* Coerce numbers to strings when passed to semver.coerce()
|
|
47
|
-
* Add `rtl` option to coerce from right to left
|
|
48
|
-
|
|
49
|
-
## 6.1.3
|
|
50
|
-
|
|
51
|
-
* Handle X-ranges properly in includePrerelease mode
|
|
52
|
-
|
|
53
|
-
## 6.1.2
|
|
54
|
-
|
|
55
|
-
* Do not throw when testing invalid version strings
|
|
56
|
-
|
|
57
|
-
## 6.1.1
|
|
58
|
-
|
|
59
|
-
* Add options support for semver.coerce()
|
|
60
|
-
* Handle undefined version passed to Range.test
|
|
61
|
-
|
|
62
|
-
## 6.1.0
|
|
63
|
-
|
|
64
|
-
* Add semver.compareBuild function
|
|
65
|
-
* Support `*` in semver.intersects
|
|
66
|
-
|
|
67
|
-
## 6.0
|
|
68
|
-
|
|
69
|
-
* Fix `intersects` logic.
|
|
70
|
-
|
|
71
|
-
This is technically a bug fix, but since it is also a change to behavior
|
|
72
|
-
that may require users updating their code, it is marked as a major
|
|
73
|
-
version increment.
|
|
74
|
-
|
|
75
|
-
## 5.7
|
|
76
|
-
|
|
77
|
-
* Add `minVersion` method
|
|
78
|
-
|
|
79
|
-
## 5.6
|
|
80
|
-
|
|
81
|
-
* Move boolean `loose` param to an options object, with
|
|
82
|
-
backwards-compatibility protection.
|
|
83
|
-
* Add ability to opt out of special prerelease version handling with
|
|
84
|
-
the `includePrerelease` option flag.
|
|
85
|
-
|
|
86
|
-
## 5.5
|
|
87
|
-
|
|
88
|
-
* Add version coercion capabilities
|
|
89
|
-
|
|
90
|
-
## 5.4
|
|
91
|
-
|
|
92
|
-
* Add intersection checking
|
|
93
|
-
|
|
94
|
-
## 5.3
|
|
95
|
-
|
|
96
|
-
* Add `minSatisfying` method
|
|
97
|
-
|
|
98
|
-
## 5.2
|
|
99
|
-
|
|
100
|
-
* Add `prerelease(v)` that returns prerelease components
|
|
101
|
-
|
|
102
|
-
## 5.1
|
|
103
|
-
|
|
104
|
-
* Add Backus-Naur for ranges
|
|
105
|
-
* Remove excessively cute inspection methods
|
|
106
|
-
|
|
107
|
-
## 5.0
|
|
108
|
-
|
|
109
|
-
* Remove AMD/Browserified build artifacts
|
|
110
|
-
* Fix ltr and gtr when using the `*` range
|
|
111
|
-
* Fix for range `*` with a prerelease identifier
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Source File : InputPredictorPNGAverageStream.cpp
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Copyright 2011 Gal Kahana PDFWriter
|
|
6
|
-
|
|
7
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
10
|
-
|
|
11
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
See the License for the specific language governing permissions and
|
|
17
|
-
limitations under the License.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
#include "InputPredictorPNGAverageStream.h"
|
|
22
|
-
|
|
23
|
-
#include "Trace.h"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
using namespace IOBasicTypes;
|
|
27
|
-
|
|
28
|
-
InputPredictorPNGAverageStream::InputPredictorPNGAverageStream(void)
|
|
29
|
-
{
|
|
30
|
-
mSourceStream = NULL;
|
|
31
|
-
mBuffer = NULL;
|
|
32
|
-
mIndex = NULL;
|
|
33
|
-
mBufferSize = 0;
|
|
34
|
-
mUpValues = NULL;
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
InputPredictorPNGAverageStream::~InputPredictorPNGAverageStream(void)
|
|
39
|
-
{
|
|
40
|
-
delete[] mBuffer;
|
|
41
|
-
delete[] mUpValues;
|
|
42
|
-
delete mSourceStream;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
InputPredictorPNGAverageStream::InputPredictorPNGAverageStream(IByteReader* inSourceStream,IOBasicTypes::LongBufferSizeType inColumns)
|
|
46
|
-
{
|
|
47
|
-
mSourceStream = NULL;
|
|
48
|
-
mBuffer = NULL;
|
|
49
|
-
mIndex = NULL;
|
|
50
|
-
mBufferSize = 0;
|
|
51
|
-
mUpValues = NULL;
|
|
52
|
-
|
|
53
|
-
Assign(inSourceStream,inColumns);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
LongBufferSizeType InputPredictorPNGAverageStream::Read(Byte* inBuffer,LongBufferSizeType inBufferSize)
|
|
58
|
-
{
|
|
59
|
-
LongBufferSizeType readBytes = 0;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// exhaust what's in the buffer currently
|
|
63
|
-
while(mBufferSize > (LongBufferSizeType)(mIndex - mBuffer) && readBytes < inBufferSize)
|
|
64
|
-
{
|
|
65
|
-
DecodeNextByte(inBuffer[readBytes]);
|
|
66
|
-
++readBytes;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// now repeatedly read bytes from the input stream, and decode
|
|
70
|
-
while(readBytes < inBufferSize && mSourceStream->NotEnded())
|
|
71
|
-
{
|
|
72
|
-
memcpy(mUpValues,mBuffer,mBufferSize);
|
|
73
|
-
LongBufferSizeType readFromSource = mSourceStream->Read(mBuffer, mBufferSize);
|
|
74
|
-
if (readFromSource == 0) {
|
|
75
|
-
break; // a belated end. must be flate
|
|
76
|
-
}
|
|
77
|
-
if (readFromSource != mBufferSize)
|
|
78
|
-
{
|
|
79
|
-
TRACE_LOG("InputPredictorPNGOptimumStream::Read, problem, expected columns number read. didn't make it");
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
*mBuffer = 0; // so i can use this as "left" value...we don't care about this one...it's just a tag
|
|
83
|
-
mIndex = mBuffer+1; // skip the first tag
|
|
84
|
-
|
|
85
|
-
while(mBufferSize > (LongBufferSizeType)(mIndex - mBuffer) && readBytes < inBufferSize)
|
|
86
|
-
{
|
|
87
|
-
DecodeNextByte(inBuffer[readBytes]);
|
|
88
|
-
++readBytes;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return readBytes;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
bool InputPredictorPNGAverageStream::NotEnded()
|
|
95
|
-
{
|
|
96
|
-
return mSourceStream->NotEnded() || (LongBufferSizeType)(mIndex - mBuffer) < mBufferSize;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
void InputPredictorPNGAverageStream::DecodeNextByte(Byte& outDecodedByte)
|
|
100
|
-
{
|
|
101
|
-
outDecodedByte = (Byte)((char)mBuffer[mIndex-mBuffer - 1]/2 + (char)mUpValues[mIndex-mBuffer]/2 + (char)*mIndex);
|
|
102
|
-
|
|
103
|
-
*mIndex = outDecodedByte; // saving the encoded value back to the buffer, for later copying as "Up value", and current using as "Left" value
|
|
104
|
-
++mIndex;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
void InputPredictorPNGAverageStream::Assign(IByteReader* inSourceStream,IOBasicTypes::LongBufferSizeType inColumns)
|
|
108
|
-
{
|
|
109
|
-
mSourceStream = inSourceStream;
|
|
110
|
-
|
|
111
|
-
delete[] mBuffer;
|
|
112
|
-
delete[] mUpValues;
|
|
113
|
-
mBufferSize = inColumns + 1;
|
|
114
|
-
mBuffer = new Byte[mBufferSize];
|
|
115
|
-
memset(mBuffer,0,mBufferSize);
|
|
116
|
-
mUpValues = new Byte[mBufferSize];
|
|
117
|
-
memset(mUpValues,0,mBufferSize); // that's less important
|
|
118
|
-
mIndex = mBuffer + mBufferSize;
|
|
119
|
-
|
|
120
|
-
}
|