diff --git a/decode.strings-tests-fixes-additionalEscapes-to-over.patch b/decode.strings-tests-fixes-additionalEscapes-to-over.patch new file mode 100644 index 0000000..f391abf --- /dev/null +++ b/decode.strings-tests-fixes-additionalEscapes-to-over.patch @@ -0,0 +1,51 @@ +From 4198da3854ccfaabcb85de23fa4cf8144e45b44d Mon Sep 17 00:00:00 2001 +From: Thomas Harning Jr +Date: Mon, 18 Apr 2016 23:12:33 -0400 +Subject: [PATCH 52/66] decode.strings+tests: fixes additionalEscapes to + override builtin escapes and side-step escapeCheck needing to be altered + +--- + lua/json/decode/strings.lua | 6 +++--- + tests/lunit-tests.lua | 6 ++++-- + 2 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/lua/json/decode/strings.lua b/lua/json/decode/strings.lua +index cb3b5cc..4272f29 100644 +--- a/lua/json/decode/strings.lua ++++ b/lua/json/decode/strings.lua +@@ -107,12 +107,12 @@ local function generateLexer(options) + local escapeMatch = doSimpleSub + escapeMatch = escapeMatch + doXSub / decodeX + escapeMatch = escapeMatch + doUniSub / options.decodeUnicode +- if options.additionalEscapes then +- escapeMatch = escapeMatch + options.additionalEscapes +- end + if options.escapeCheck then + escapeMatch = options.escapeCheck * escapeMatch + bad_escape + end ++ if options.additionalEscapes then ++ escapeMatch = options.additionalEscapes + escapeMatch ++ end + local captureString + for i = 1, #quotes do + local cap = buildCaptureString(quotes[i], options.badChars, escapeMatch) +diff --git a/tests/lunit-tests.lua b/tests/lunit-tests.lua +index 10f38cb..d2f183f 100644 +--- a/tests/lunit-tests.lua ++++ b/tests/lunit-tests.lua +@@ -44,8 +44,10 @@ function test_preprocess() + end + + function test_additionalEscapes_only() +- -- Need to do escape while skipping escape character san-check +- assert_equal("Hello", json.decode([["\S"]], { strings = { additionalEscapes = lpeg.C(lpeg.P("S")) / "Hello", escapeCheck= false } })) ++ -- Test that additionalEscapes is processed on its own - side-stepping normal processing ++ assert_equal("Hello\\?", json.decode([["\S"]], { strings = { additionalEscapes = lpeg.C(lpeg.P("S")) / "Hello\\?" } })) ++ -- Test that additionalEscapes overrides any builtin handling ++ assert_equal("Hello\\?", json.decode([["\n"]], { strings = { additionalEscapes = lpeg.C(lpeg.P("n")) / "Hello\\?" } })) + end + + local strictDecoder = json.decode.getDecoder(true) +-- +2.19.1 + diff --git a/lua-json.spec b/lua-json.spec index 949c052..aa4b80a 100644 --- a/lua-json.spec +++ b/lua-json.spec @@ -1,6 +1,6 @@ Name: lua-json Version: 1.3.2 -Release: 12 +Release: 13 License: MIT Summary: JSON Parser/Constructor for Lua @@ -20,13 +20,15 @@ Requires: lua >= %{luaversion}, lua-lpeg >= 0.8.1 Patch0: luajson-lua-5.2.patch +Patch6000: tests-enhances-coverage-for-strings.additionalEscape.patch +Patch6001: decode.strings-tests-fixes-additionalEscapes-to-over.patch + %description JSON parser/encoder for Lua Parses JSON using LPEG for speed and flexibility. Depending on parser/encoder options, various values are preserved as best as possible. %prep -%setup -q -n luajson-%{commitid} -%patch0 -p1 -b .lua-52 +%autosetup -n luajson-%{commitid} -p1 %build @@ -42,6 +44,12 @@ make check-regression %{luapkgdir}/* %changelog +* Fri Dec 20 2019 chengquan - 1.3.2-13 +- Type:enhancement +- ID:NA +- SUG:NA +- DESC:quality enhancement synchronization github patch + * Thu Sep 5 2019 openEuler Buildteam - 1.3.2-12 - Fix package name diff --git a/tests-enhances-coverage-for-strings.additionalEscape.patch b/tests-enhances-coverage-for-strings.additionalEscape.patch new file mode 100644 index 0000000..25cbbd5 --- /dev/null +++ b/tests-enhances-coverage-for-strings.additionalEscape.patch @@ -0,0 +1,46 @@ +From 4556f70aa8fd4826551399701144ec56f4733954 Mon Sep 17 00:00:00 2001 +From: Thomas Harning Jr +Date: Mon, 18 Apr 2016 23:08:49 -0400 +Subject: [PATCH] tests: enhances coverage for strings.additionalEscapes + decoding option + +--- + tests/lunit-tests.lua | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/tests/lunit-tests.lua b/tests/lunit-tests.lua +index 30e82df..d25216c 100644 +--- a/tests/lunit-tests.lua ++++ b/tests/lunit-tests.lua +@@ -1,6 +1,7 @@ + local json = require("json") + local lunit = require("lunit") + local testutil = require("testutil") ++local lpeg = require("lpeg") + -- DECODE NOT 'local' due to requirement for testutil to access it + decode = json.decode.getDecoder(false) + +@@ -35,6 +36,11 @@ function test_preprocess() + assert_equal('-Infinity', json.encode(1/0, {preProcess = function(x) return -x end})) + end + ++function test_additionalEscapes_only() ++ -- Need to do escape while skipping escape character san-check ++ assert_equal("Hello", json.decode([["\S"]], { strings = { additionalEscapes = lpeg.C(lpeg.P("S")) / "Hello", escapeCheck= false } })) ++end ++ + local strictDecoder = json.decode.getDecoder(true) + + local function buildStrictDecoder(f) +@@ -45,7 +51,7 @@ local function buildFailedStrictDecoder(f) + end + -- SETUP CHECKS FOR SEQUENCE OF DECODERS + for k, v in pairs(_M) do +- if k:match("^test_") and not k:match("_gen$") then ++ if k:match("^test_") and not k:match("_gen$") and not k:match("_only$") then + if k:match("_nostrict") then + _M[k .. "_strict_gen"] = buildFailedStrictDecoder(v) + else +-- +1.8.3.1 +