[data_scanner] fix quoted string regex

Fixes #842
This commit is contained in:
Timothy Stack 2021-03-02 15:19:08 -08:00
parent c177a321fb
commit 68759ada2d
5 changed files with 41121 additions and 44385 deletions

20
.readthedocs.yaml Normal file
View File

@ -0,0 +1,20 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py
# Optionally build your docs in additional formats such as PDF
formats:
- pdf
# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/requirements.txt

View File

@ -1,4 +1,5 @@
[![Build](https://github.com/tstack/lnav/workflows/ci-build/badge.svg)](https://github.com/tstack/lnav/actions?query=workflow%3Aci-build)
[![Docs](https://readthedocs.org/projects/lnav/badge/?version=latest&style=plastic)](https://docs.lnav.org)
[![Coverage Status](https://coveralls.io/repos/github/tstack/lnav/badge.svg?branch=master)](https://coveralls.io/github/tstack/lnav?branch=master)
[![lnav](https://snapcraft.io//lnav/badge.svg)](https://snapcraft.io/lnav)

File diff suppressed because it is too large Load Diff

View File

@ -137,7 +137,7 @@ bool data_scanner::tokenize2(pcre_context &pc, data_token_t &token_out)
EOF { return false; }
("u"|"r")?'"'('\\'.|'""'|[^\x00\"])*'"' {
("u"|"r")?'"'('\\'.|[^\x00\"\\]|'""')*'"' {
CAPTURE(DT_QUOTED_STRING);
switch (pi.get_string()[cap[1].c_begin]) {
case 'u':
@ -152,7 +152,7 @@ bool data_scanner::tokenize2(pcre_context &pc, data_token_t &token_out)
[a-qstv-zA-QSTV-Z]"'" {
CAPTURE(DT_WORD);
}
("u"|"r")?"'"('\\'.|"''"|[^\x00\'])*"'"/[^sS] {
("u"|"r")?"'"('\\'.|"''"|[^\x00\'\\])*"'"/[^sS] {
CAPTURE(DT_QUOTED_STRING);
switch (pi.get_string()[cap[1].c_begin]) {
case 'u':
@ -180,11 +180,11 @@ bool data_scanner::tokenize2(pcre_context &pc, data_token_t &token_out)
}
IPV6ADDR/[^:a-zA-Z0-9] { RET(DT_IPV6_ADDRESS); }
"<""?"?[a-zA-Z0-9_:\-]+SPACE*([a-zA-Z0-9_:\-]+(SPACE*'='SPACE*('"'(('\\'.|[^\x00"])+)'"'|"'"(('\\'.|[^\x00'])+)"'"|[^\x00>]+)))*SPACE*("/"|"?")">" {
"<""?"?[a-zA-Z0-9_:\-]+SPACE*([a-zA-Z0-9_:\-]+(SPACE*'='SPACE*('"'(('\\'.|[^\x00"\\])+)'"'|"'"(('\\'.|[^\x00'\\])+)"'"|[^\x00>]+)))*SPACE*("/"|"?")">" {
RET(DT_XML_EMPTY_TAG);
}
"<"[a-zA-Z0-9_:\-]+SPACE*([a-zA-Z0-9_:\-]+(SPACE*"="SPACE*('"'(('\\'.|[^\x00"])+)'"'|"'"(('\\'.|[^\x00'])+)"'"|[^\x00>]+)))*SPACE*">" {
"<"[a-zA-Z0-9_:\-]+SPACE*([a-zA-Z0-9_:\-]+(SPACE*"="SPACE*('"'(('\\'.|[^\x00"\\])+)'"'|"'"(('\\'.|[^\x00'\\])+)"'"|[^\x00>]+)))*SPACE*">" {
RET(DT_XML_OPEN_TAG);
}

26
test/datafile_simple.21 Normal file
View File

@ -0,0 +1,26 @@
{"correctProperty":"test", "incorrectProperty": "test\"", "nextProperty":"test"}
key 2:2 ^
quot 2:17 ^-------------^ correctProperty
val 2:17 ^-------------^ correctProperty
quot 20:24 ^--^ test
val 20:24 ^--^ test
quot 28:45 ^---------------^ incorrectProperty
val 28:45 ^---------------^ incorrectProperty
quot 49:55 ^----^ test\"
val 49:55 ^----^ test\"
quot 59:71 ^----------^ nextProperty
val 59:71 ^----------^ nextProperty
quot 74:78 ^--^ test
val 74:78 ^--^ test
grp 2:78 ^--------------------------------------------------------------------------^ correctProperty":"test", "incorrectProperty": "test\"", "nextProperty":"test
pair 2:78 ^--------------------------------------------------------------------------^ correctProperty":"test", "incorrectProperty": "test\"", "nextProperty":"test
msg :{"correctProperty":"test", "incorrectProperty": "test\"", "nextProperty":"test"}
format :{#}
[
"correctProperty",
"test",
"incorrectProperty",
"test\\\"",
"nextProperty",
"test"
]