SHA256
1
0
forked from pool/lua-slaxml

Compare commits

3 Commits

Author SHA256 Message Date
50257d68ae Switch off building lua51 build of the package. 2025-10-24 17:09:12 +02:00
1e87334110 Fix the test suite to pass even with LuaJIT.
Update to version 0.7+git20230101.756ffad:
  * Indicate compatibility with 5.1-5.4, inclusive
  * Update rockspec for v0.8.1
2025-10-13 12:35:52 +02:00
1215409bc6 Add luajit version to _multibuild 2025-10-06 10:49:53 +02:00
10 changed files with 117 additions and 13 deletions

1
.gitattributes vendored
View File

@@ -21,3 +21,4 @@
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*.changes merge=merge-changes

6
.gitignore vendored
View File

@@ -1 +1,7 @@
.osc
*.obscpio
*.osc
_build.*
.pbuild
SLAXML/
lua*-slaxml-*-build/

View File

@@ -1,5 +1,5 @@
<multibuild>
<package>lua51</package>
<package>luajit</package>
<package>lua53</package>
<package>lua54</package>
</multibuild>

View File

@@ -1,14 +1,14 @@
<services>
<service name="tar_scm" mode="disabled">
<service name="tar_scm" mode="manual">
<param name="url">https://github.com/Phrogz/SLAXML.git</param>
<param name="filename">lua-slaxml</param>
<param name="versionformat">0.7+git%cd.%h</param>
<param name="scm">git</param>
<param name="changesgenerate">enable</param>
</service>
<service name="recompress" mode="disabled">
<service name="recompress" mode="manual">
<param name="compression">xz</param>
<param name="file">*.tar</param>
</service>
<service name="set_version" mode="disabled" />
<service name="set_version" mode="manual" />
</services>

View File

@@ -3,4 +3,4 @@
<param name="url">https://github.com/antlarr/lua-mpris</param>
<param name="changesrevision">2b12542d29f8f5f366a1dc047a82ee65bd735b41</param></service><service name="tar_scm">
<param name="url">https://github.com/Phrogz/SLAXML.git</param>
<param name="changesrevision">938dd5d5b9bb2a45663a5f310ab373c7f4461fbc</param></service></servicedata>
<param name="changesrevision">756ffad03d2a06271170a0ba82d6eac02cc2a5ca</param></service></servicedata>

75
fix_tests.patch Normal file
View File

@@ -0,0 +1,75 @@
---
slaxml.lua | 13 +++++++++++--
test/test.lua | 9 +++++++--
2 files changed, 18 insertions(+), 4 deletions(-)
Index: lua-slaxml-0.7+git20230101.756ffad/slaxml.lua
===================================================================
--- lua-slaxml-0.7+git20230101.756ffad.orig/slaxml.lua 2025-10-13 12:17:02.427586573 +0200
+++ lua-slaxml-0.7+git20230101.756ffad/slaxml.lua 2025-10-13 12:17:19.072469712 +0200
@@ -74,7 +74,13 @@
end
local entityMap = { ["lt"]="<", ["gt"]=">", ["amp"]="&", ["quot"]='"', ["apos"]="'" }
local entitySwap = function(orig,n,s) return entityMap[s] or n=="#" and utf8(tonumber('0'..s)) or orig end
- local function unescape(str) return gsub( str, '(&(#?)([%d%a]+);)', entitySwap ) end
+ local function unescape(str)
+ local s = gsub(str, '(&(#?)([%d%a]+);)', "") -- remove all valid entities
+ if find(s, '&') then
+ error("Invalid ampersand in string: "..str)
+ end
+ return gsub( str, '(&(#?)([%d%a]+);)', entitySwap )
+ end
local function finishText()
if first>textStart and self._call.text then
@@ -135,7 +141,7 @@
for i=#nsStack,1,-1 do if nsStack[i]['!'] then currentElement[2] = nsStack[i]['!']; break end end
end
currentAttributeCt = 0
- push(nsStack,{})
+ push(nsStack,{['__name__']=currentElement[1]})
return true
end
end
@@ -153,6 +159,8 @@
if first then
pos = last+1
match2 = unescape(match2)
+ else
+ error("Attribute value must be quoted for attribute: "..match1)
end
end
end
@@ -225,6 +233,7 @@
end
if first then
finishText()
+ if nsStack[#nsStack]['__name__'] ~= match1 then error("Mismatched closing tag: expected "..nsStack[#nsStack]['__name__']..", got "..match1) end
if self._call.closeElement then self._call.closeElement(match1,nsURI) end
pos = last+1
textStart = pos
Index: lua-slaxml-0.7+git20230101.756ffad/test/test.lua
===================================================================
--- lua-slaxml-0.7+git20230101.756ffad.orig/test/test.lua 2025-10-13 12:17:02.428324592 +0200
+++ lua-slaxml-0.7+git20230101.756ffad/test/test.lua 2025-10-13 12:17:19.072959653 +0200
@@ -1,5 +1,10 @@
package.path = '../?.lua;' .. package.path
-_ENV = require('lunity')()
+local env = require('lunity')()
+if _VERSION:find("5.1") then
+ setfenv(1, env)
+else
+ _ENV = env
+end
local SLAXML = require 'slaxdom'
@@ -218,7 +223,7 @@
end
function test:invalid_documents()
- local silentParser = SLAXML:parser{}
+ local silentParser = SLAXML:parser{ text = function() end }
assertErrors(silentParser.parse, silentParser, XML['invalid_unquoted'] )
assertErrors(silentParser.parse, silentParser, XML['invalid_pi_only'] )
assertErrors(silentParser.parse, silentParser, XML['invalid_unclosed_tags'] )

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e37c689a77a9ed4ecd565b7d7719c4f39112f0f156cd5779f4f457901460b332
size 15528

Binary file not shown.

View File

@@ -1,3 +1,22 @@
-------------------------------------------------------------------
Fri Oct 24 14:51:04 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
- Switch off building lua51 build of the package.
-------------------------------------------------------------------
Mon Oct 13 10:02:39 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
- Add fix_tests.patch (gh#Phrogz/SLAXML!22) to improve parser
strictness and error handling. Goal was originally to make the
test suite to pass even on LuaJIT.
-------------------------------------------------------------------
Mon Oct 13 09:33:04 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
- Update to version 0.7+git20230101.756ffad:
* Indicate compatibility with 5.1-5.4, inclusive
* Update rockspec for v0.8.1
-------------------------------------------------------------------
Wed Jan 25 11:52:07 UTC 2023 - Michal Suchanek <msuchanek@suse.de>

View File

@@ -18,13 +18,16 @@
%define flavor @BUILD_FLAVOR@
%define mod_name slaxml
Version: 0.7+git20191225.108970c
Version: 0.7+git20230101.756ffad
Release: 0
Summary: SAX-like streaming XML parser for Lua
License: MIT
Group: Development/Libraries/Other
URL: https://github.com/Phrogz/SLAXML
Source: lua-slaxml-%{version}.tar.xz
# PATCH-FIX-UPSTREAM fix_tests.patch gh#Phrogz/SLAXML!22 mcepl@suse.com
# unescape() function was too lenient
Patch0: fix_tests.patch
BuildRequires: lua-macros
BuildRequires: %{flavor}-devel
BuildArch: noarch
@@ -49,7 +52,9 @@ it allows certain XML that is syntactically-invalid (not
well-formed) to be parsed without reporting an error.
%prep
%autosetup -p1 -n lua-slaxml-%{version}
%setup -q -n lua-slaxml-%{version}
find . -name \*.lua -exec sed -i 's/\r/\n/g; s/\n$//' '{}' +
%autopatch -p1
%build
@@ -57,13 +62,11 @@ well-formed) to be parsed without reporting an error.
install -D -m 0644 -t %{buildroot}%{lua_noarchdir} slaxml.lua slaxdom.lua
%check
%if "%{flavor}" != "lua51"
cd test
lua test.lua
%endif
%files
%license LICENSE.txt
%{lua_noarchdir}/*
%{lua_noarchdir}/slax*.lua
%changelog