mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-05-05 04:16:46 +02:00
main/liblognorm: add patch for quoting support in parse-name-value
This commit is contained in:
parent
d37614ce58
commit
7ead648e80
@ -2,7 +2,7 @@
|
||||
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
|
||||
pkgname=liblognorm
|
||||
pkgver=2.0.6
|
||||
pkgrel=0
|
||||
pkgrel=1
|
||||
pkgdesc="A fast log-normalization library"
|
||||
url="http://www.liblognorm.com"
|
||||
arch="all"
|
||||
@ -11,7 +11,9 @@ depends_dev="libestr-dev"
|
||||
checkdepends="bash"
|
||||
makedepends="$depends_dev libfastjson-dev"
|
||||
subpackages="$pkgname-dev"
|
||||
source="http://www.liblognorm.com/files/download/$pkgname-$pkgver.tar.gz"
|
||||
source="http://www.liblognorm.com/files/download/$pkgname-$pkgver.tar.gz
|
||||
parse-name-value-quoting-support.patch
|
||||
"
|
||||
builddir="$srcdir/$pkgname-$pkgver"
|
||||
|
||||
build() {
|
||||
@ -35,4 +37,5 @@ package() {
|
||||
make DESTDIR="$pkgdir" install
|
||||
}
|
||||
|
||||
sha512sums="0b4ee55eb54920dd096fdd6d6dcc2263bc52e74442d86503bfebf26b31492a8c1b67cb3b709ecc8b96cc53252151515719027306b2b6f7ba3404adc5a48cf125 liblognorm-2.0.6.tar.gz"
|
||||
sha512sums="0b4ee55eb54920dd096fdd6d6dcc2263bc52e74442d86503bfebf26b31492a8c1b67cb3b709ecc8b96cc53252151515719027306b2b6f7ba3404adc5a48cf125 liblognorm-2.0.6.tar.gz
|
||||
0cebeda088e6e1c98aa370b7efbefde6d208540c7e02637940f87763535f8d6134a81a813640d7d4fa6f8ee0454e456ac9d133b4dced17f0ea8d0a3cb4c8542f parse-name-value-quoting-support.patch"
|
||||
|
||||
84
main/liblognorm/parse-name-value-quoting-support.patch
Normal file
84
main/liblognorm/parse-name-value-quoting-support.patch
Normal file
@ -0,0 +1,84 @@
|
||||
From 69392daac575cc29f9f3bf8f7369fae52f3fadf0 Mon Sep 17 00:00:00 2001
|
||||
From: Benoit DOLEZ <bdolez@pom-monitoring.com>
|
||||
Date: Thu, 15 Dec 2016 00:16:27 +0100
|
||||
Subject: [PATCH] parseNameValue: fix no quoting support
|
||||
|
||||
Function description announce support of quoted variable :
|
||||
- name=value
|
||||
- name="value"
|
||||
- name='value'
|
||||
|
||||
... but there is nothing in the code to really support quoted string.
|
||||
I had small fixes to support it.
|
||||
|
||||
My tests :
|
||||
$ cat > test.txt <<EOF
|
||||
a=
|
||||
a=123
|
||||
a=123
|
||||
a='123'
|
||||
a="123"
|
||||
a=123 b=456
|
||||
a=123 b="456"
|
||||
a=123 b="456" c=
|
||||
a=123 b="456'789" c=
|
||||
a=123 b="456 789" c=
|
||||
a=123 b="456 789' c=
|
||||
a=123 b=456 789 c=
|
||||
EOF
|
||||
|
||||
$ cat > test.rb << EOF
|
||||
version=2
|
||||
rule=test-ok:%[
|
||||
{"type": "name-value-list"}
|
||||
]%
|
||||
EOF
|
||||
|
||||
$ cat test.txt | ./lognormalizer -r test.rb -T
|
||||
{ "event.tags": [ "test-ok" ] }
|
||||
{ "event.tags": [ "test-ok" ] }
|
||||
{ "event.tags": [ "test-ok" ] }
|
||||
{ "event.tags": [ "test-ok" ] }
|
||||
{ "event.tags": [ "test-ok" ] }
|
||||
{ "event.tags": [ "test-ok" ] }
|
||||
{ "event.tags": [ "test-ok" ] }
|
||||
{ "event.tags": [ "test-ok" ] }
|
||||
{ "event.tags": [ "test-ok" ] }
|
||||
{ "event.tags": [ "test-ok" ] }
|
||||
{ "originalmsg": "a=123 b=\"456 789' c= ", "unparsed-data": "a=123 b=\"456 789' c= " }
|
||||
{ "originalmsg": "a=123 b=456 789 c= ", "unparsed-data": "a=123 b=456 789 c= " }
|
||||
---
|
||||
src/parser.c | 14 +++++++++++++-
|
||||
1 file changed, 13 insertions(+), 1 deletion(-)
|
||||
|
||||
Patch-Source: https://github.com/rsyslog/liblognorm/pull/234
|
||||
|
||||
diff --git a/src/parser.c b/src/parser.c
|
||||
index 7068362..74111f6 100644
|
||||
--- a/src/parser.c
|
||||
+++ b/src/parser.c
|
||||
@@ -1967,11 +1967,23 @@ parseNameValue(npb_t *const npb,
|
||||
const size_t lenName = i - iName;
|
||||
++i; /* skip '=' */
|
||||
|
||||
+ char quoting = npb->str[i]; // end of string
|
||||
+ if (i < npb->strLen && (quoting == '"' || quoting == '\''))
|
||||
+ ++i;
|
||||
+ else
|
||||
+ quoting = 0; // str[i] can't be null, is a good default value
|
||||
+
|
||||
const size_t iVal = i;
|
||||
- while(i < npb->strLen && !isspace(npb->str[i]))
|
||||
+ while(i < npb->strLen &&
|
||||
+ ((quoting && npb->str[i] != quoting) || (!quoting && !isspace(npb->str[i]))))
|
||||
++i;
|
||||
const size_t lenVal = i - iVal;
|
||||
|
||||
+ if (i < npb->strLen && npb->str[i] == quoting)
|
||||
+ ++i;
|
||||
+ else if (quoting)
|
||||
+ goto done;
|
||||
+
|
||||
/* parsing OK */
|
||||
*offs = i;
|
||||
r = 0;
|
||||
Loading…
x
Reference in New Issue
Block a user