From e65024a0c25f7682a5c0b170130956817c85b9a2 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 21 Dec 2015 04:48:44 +0000 Subject: Add support for escaped string content in unpack of PQ arrays --- gentoobrowse-api/service/unpackPqTextArray.ll | 31 ++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/gentoobrowse-api/service/unpackPqTextArray.ll b/gentoobrowse-api/service/unpackPqTextArray.ll index 6281063..9c53157 100644 --- a/gentoobrowse-api/service/unpackPqTextArray.ll +++ b/gentoobrowse-api/service/unpackPqTextArray.ll @@ -17,11 +17,14 @@ begin "{" end "}" comma , unquoted [^,\"}]+ -quoted (\"[^\"]+\") +quote \" +esc \\. +char [^"] %x FIRST %x AFTER %x NEXT +%x QUOTED %% @@ -35,14 +38,32 @@ quoted (\"[^\"]+\") list.push_back(YYText()); BEGIN(AFTER); } -{quoted} { - list.push_back(YYText()); - boost::algorithm::trim_if(list.back(), [](auto c){ return c == '"'; }); - BEGIN(AFTER); +{quote} { + list.push_back(std::string()); + BEGIN(QUOTED); } {comma} { BEGIN(NEXT); } +{quote} { + BEGIN(AFTER); +} +{esc} { + switch (*(YYText() + 1)) { + case '"': + list.back().push_back('"'); + break; + case '\\': + list.back().push_back('\\'); + break; + case 'n': + list.back().push_back('\n'); + break; + } +} +{char} { + list.back().append(YYText()); +} %% -- cgit v1.2.3