AnsweredAssumed Answered

Lua Parser Help

Question asked by RSA Admin Employee on Dec 19, 2014
Latest reply on Dec 30, 2014 by Christopher Ahearn

I've been looking at the parser book created by William Motley and I've been trying to use a variation of the sample parser, but I keep getting the following error.

 

[Parse]  Meta processing failed for session with: Unmatched [ or [^ in character class declaration.  The error occured while parsing the regular expression: '9]{10}/[0>>>HERE>>>'.

 

Looking at the book it says you can't do pattern matching with payload:find, but that is exactly what is being done with the example in the book.

 

Here is the parser example I'm trying to get to work.  Keep in mind this is just to test, I want it to return meta for what stored into the endOfLine variable.  Obviously I'll be changing this prior to production.

 

local getHeader = nw.createParser("noHeader", "Test Meta")

getHeader:setKeys( {nwlanguagekey.create('risk.info')})

 

function getHeader:httpGet(token, first, last)

    local payload = nw.getPayload()   

    local endOfLine = payload:find("\013\010\\013\010", last + 1, last + 100)

    if endOfLine then

        local header = payload:tostring(last + 1, endOfLine - 1)

        if header then

            nw.createMeta(self.keys{"risk.info"], header)   

        end 

    end

end

noHeader:setCallbacks({

    ["^GET "] = getHeader.httpGet,

})

Outcomes