From 244a960a509ce4b8476f0ad9e3e3d1cd4bc381d6 Mon Sep 17 00:00:00 2001 From: Paul Gardiner Date: Tue, 6 Nov 2018 15:23:40 +0000 Subject: Update AFParseDateEx to handle dates as a contiguous string of digits. Update to match Adobe Reader's behaviour. This fixes bug #700128. --- source/pdf/js/util.js | 13 +++++++++++++ source/pdf/js/util.js.h | 13 +++++++++++++ 2 files changed, 26 insertions(+) (limited to 'source') diff --git a/source/pdf/js/util.js b/source/pdf/js/util.js index dd58dff7..038014c3 100644 --- a/source/pdf/js/util.js +++ b/source/pdf/js/util.js @@ -554,6 +554,19 @@ function AFParseDateEx(d, fmt) { dout.setHours(12, 0, 0); + if (nums.length == 1 && nums[0].length == fmt.length && !text_month) { + // One number string, exactly matching the format string in length. + // Split it into separate strings to match the fmt + var num = nums[0]; + nums = [""]; + for (i = 0; i < fmt.length; i++) + { + nums[nums.length-1] += num.charAt(i); + if (i+1 < fmt.length && fmt.charAt(i) != fmt.charAt(i+1)) + nums.push(""); + } + } + if (!nums || nums.length < 1 || nums.length > 3) return null; diff --git a/source/pdf/js/util.js.h b/source/pdf/js/util.js.h index a8bf9619..2cf8a0af 100644 --- a/source/pdf/js/util.js.h +++ b/source/pdf/js/util.js.h @@ -554,6 +554,19 @@ "\n" "dout.setHours(12, 0, 0);\n" "\n" +"if (nums.length == 1 && nums[0].length == fmt.length && !text_month) {\n" +"\n" +"\n" +"var num = nums[0];\n" +"nums = [\"\"];\n" +"for (i = 0; i < fmt.length; i++)\n" +"{\n" +"nums[nums.length-1] += num.charAt(i);\n" +"if (i+1 < fmt.length && fmt.charAt(i) != fmt.charAt(i+1))\n" +"nums.push(\"\");\n" +"}\n" +"}\n" +"\n" "if (!nums || nums.length < 1 || nums.length > 3)\n" "return null;\n" "\n" -- cgit v1.2.3