How to crash a RegEx droplet...
How to crash a RegEx droplet...
- Subject: How to crash a RegEx droplet...
- From: Hans Haesler <email@hidden>
- Date: Fri, 11 May 2001 22:18:01 +0200
One of my droplets is used by our layouters to import text files
in QuarkXPress text boxes. The script does a lot of things, including
cleaning up the text.
It works nicely, since 44 weeks, for our Sunday newspaper. Three weeks
ago we introduced it to two magazines and yesterday a colleague reported
a crash (of the droplet first and, on the second try, of the system).
I tracked the problem down to the line where RegEx replaces double (or more)
spaces by one space.
The typist, instead of typing a tab, had inserted 135 spaces to position
a word in a line...
Using this simple snippet I tried to find the limit ...
---
set aSt to "a z"
set aSt to (REReplace aSt pattern "( )+( )" with " ")
-->"a z"
... and had no "success" up to 128 spaces. With 129 spaces or more there is,
at best, a crash of Script Editor (type 2 or 3). At worst, a bomb (bus error).
To prevent further problems I'll insert a new command line which replaces,
first, 20 spaces by one, pushing the limit up to 2560 spaces... unless
Leonard or Lindsey (or any other RegExpert) can point out another solution.
Hans
---
Hans Haesler | email@hidden