update to 1.3.4

This commit is contained in:
dillon_chen 2022-06-27 11:09:30 +08:00
parent e4583c5466
commit 3fa4daabe7
6 changed files with 6 additions and 129 deletions

Binary file not shown.

BIN
1.3.4.tar.gz Normal file

Binary file not shown.

View File

@ -1,51 +0,0 @@
From 4198da3854ccfaabcb85de23fa4cf8144e45b44d Mon Sep 17 00:00:00 2001
From: Thomas Harning Jr <harningt@gmail.com>
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

View File

@ -1,6 +1,6 @@
Name: lua-json
Version: 1.3.2
Release: 14
Version: 1.3.4
Release: 1
License: MIT
Summary: JSON Parser/Constructor for Lua
@ -10,7 +10,7 @@ Summary: JSON Parser/Constructor for Lua
%global shortid %(c=%{commitid}; echo ${c:0:7})
URL: http://github.com/harningt/luajson/
Source0: https://github.com/harningt/luajson/archive/%{version}.tar.gz
Source0: https://github.com/harningt/luajson/archive/refs/tags/%{version}.tar.gz
# for build and check
BuildRequires: lua >= %{luaversion}, lua-lpeg >= 0.8.1
BuildRequires: lua-filesystem >= 1.4.1, lua-lunit >= 0.4
@ -18,11 +18,6 @@ BuildArch: noarch
# for run
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.
@ -44,6 +39,9 @@ make check-regression
%{luapkgdir}/*
%changelog
* Mon Jun 27 2022 dillon chen <dillon.chen@gmail.com> -1.3.4-1
- update to 1.3.4
* Tue Sep 8 2020 shixuantong <shixuantong@huawei.com> - 1.3.2-14
- Type: bugfix
- ID: NA

View File

@ -1,24 +0,0 @@
diff -up luajson-7a86bc22066858afeb23845a191a6ab680b46233/lua/json/decode/state.lua.lua-52 luajson-7a86bc22066858afeb23845a191a6ab680b46233/lua/json/decode/state.lua
--- luajson-7a86bc22066858afeb23845a191a6ab680b46233/lua/json/decode/state.lua.lua-52 2013-05-10 16:32:47.277329679 -0400
+++ luajson-7a86bc22066858afeb23845a191a6ab680b46233/lua/json/decode/state.lua 2013-05-10 16:33:19.301328534 -0400
@@ -8,7 +8,7 @@ local jsonutil = require("json.util")
local assert = assert
local type = type
local next = next
-local unpack = unpack
+local unpack = table.unpack
local _ENV = nil
diff -up luajson-7a86bc22066858afeb23845a191a6ab680b46233/tests/lunit-encoderfunc.lua.lua-52 luajson-7a86bc22066858afeb23845a191a6ab680b46233/tests/lunit-encoderfunc.lua
--- luajson-7a86bc22066858afeb23845a191a6ab680b46233/tests/lunit-encoderfunc.lua.lua-52 2013-05-10 16:31:50.764331699 -0400
+++ luajson-7a86bc22066858afeb23845a191a6ab680b46233/tests/lunit-encoderfunc.lua 2013-05-10 16:32:00.788331341 -0400
@@ -8,7 +8,7 @@ local setmetatable = setmetatable
module("lunit-encoderfunc", lunit.testcase, package.seeall)
local function build_call(name, parameters)
- return json.util.buildCall(name, unpack(parameters, parameters.n))
+ return json.util.buildCall(name, table.unpack(parameters, parameters.n))
end
function test_param_counts()

View File

@ -1,46 +0,0 @@
From 4556f70aa8fd4826551399701144ec56f4733954 Mon Sep 17 00:00:00 2001
From: Thomas Harning Jr <harningt@gmail.com>
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