[Pkg-javascript-commits] [pdf.js] 90/157: Ignore double negative in `Lexer_getNumber` (issue 6218)
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 06:46:41 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit c718d1ab103b307594e660928679a308c6ed36b6
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Thu Jul 16 12:11:49 2015 +0200
Ignore double negative in `Lexer_getNumber` (issue 6218)
Basic mathematics would suggest that a double negative should always become positive, but it appears that Adobe Reader simply ignores that case. Hence I think that it makes sense for us to do the same.
Fixes 6218.
---
src/core/parser.js | 5 +++++
test/unit/parser_spec.js | 7 +++++++
2 files changed, 12 insertions(+)
diff --git a/src/core/parser.js b/src/core/parser.js
index 6c98b08..62a2482 100644
--- a/src/core/parser.js
+++ b/src/core/parser.js
@@ -671,6 +671,11 @@ var Lexer = (function LexerClosure() {
if (ch === 0x2D) { // '-'
sign = -1;
ch = this.nextChar();
+
+ if (ch === 0x2D) { // '-'
+ // Ignore double negative (this is consistent with Adobe Reader).
+ ch = this.nextChar();
+ }
} else if (ch === 0x2B) { // '+'
ch = this.nextChar();
}
diff --git a/test/unit/parser_spec.js b/test/unit/parser_spec.js
index 4fb9089..24e18de 100644
--- a/test/unit/parser_spec.js
+++ b/test/unit/parser_spec.js
@@ -27,6 +27,13 @@ describe('parser', function() {
}
});
+ it('should ignore double negative before number', function() {
+ var input = new StringStream('--205.88');
+ var lexer = new Lexer(input);
+ var result = lexer.getNumber();
+
+ expect(result).toEqual(-205.88);
+ });
it('should handle glued numbers and operators', function() {
var input = new StringStream('123ET');
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list