Jump to content


Photo

Dealing with incoming strings with special characters in them


  • Please log in to reply
5 replies to this topic

#1 blackbear

blackbear

    Member

  • Members
  • PipPip
  • 13 posts

Posted 31 August 2011 - 08:56 PM

I'm trying to switch over from perl to lua, since perl support under Lion seems to be heading into the "not in my lifetime" territory (for sad reasons, but still...)

So I have an event triggering on matches regexp for ^(.+)$ It's defined as:

require "shangrila"
process_line("%{regexp.1}")

This works great, unless the incoming line contains a " or ', in which case it barfs with:


%% Error: [string "?"]:2: ')' expected near 'that'

How do I get the string properly quoted so I can work with it?

#2 wombat

wombat

    Advanced Member

  • Members
  • PipPipPip
  • 321 posts

Posted 01 September 2011 - 06:20 PM

I don't use Lua, but I'm assuming it's this:
process_line(AtlantisState["regexp.1"])

#3 blackbear

blackbear

    Member

  • Members
  • PipPip
  • 13 posts

Posted 03 September 2011 - 07:18 PM

Nope, still getting the same error

#4 Sparks

Sparks

    Atlantis Author

  • Root Admin
  • PipPipPip
  • 1,791 posts
  • Gender:Female
  • Location:Seattle, WA
  • Interests:Cocoa, Obj-C, iPhone, horses, writing

Posted 04 September 2011 - 12:26 PM

The latter /should/ work, since the regexp.1 state variable (as added to the Lua state) is a string literal; Lua should in theory already have it escaped, and does when I test it in a quicky test Lua script.

How are you calling the Lua script? If you can give me an easy repro case I'll take a look to see what might be happening.
Rachel "Sparks" Blackman
Riverdark Studios

#5 blackbear

blackbear

    Member

  • Members
  • PipPip
  • 13 posts

Posted 04 September 2011 - 07:46 PM

Ok, that's working now, I had a call to the other version elsewhere in the script. However, another question. I need to see blank lines that are sent from the server to figure out state, but the pattern:

(.*)

or

^(.*)$

With condition "matches regexp" doesn't fire the event on a blank line from the server.

#6 Sparks

Sparks

    Atlantis Author

  • Root Admin
  • PipPipPip
  • 1,791 posts
  • Gender:Female
  • Location:Seattle, WA
  • Interests:Cocoa, Obj-C, iPhone, horses, writing

Posted 05 September 2011 - 08:04 PM

That seems like a legitimate bug; it looks like I'm not firing events on zero-length lines. :( I'll change that for the next build.
Rachel "Sparks" Blackman
Riverdark Studios




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users