Suggestion for SafeChars plugin

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
May 29, 2008
521
3
Groton, CT
#1
Charles,

Would you consider adding these two functions?

@SAFECHECK[var] returns 1 if there are any characters in the translated range within the expansion of %var%, else 0.

@UNSAFECHECK[var] returns 1 if there are any characters which WOULD BE translated to safe characters (by @SAFEENV[var], according to the current translation map) within the expansion of %var%, else 0.
 
#2
Actually a single function with 4 different values would be sufficient:
0 if all characters are inherently safe;
add 1 if untranslated unsafe characters are present;
add 2 if translated unsafe characters are present.

Value 1 would mean at least one unsafe character is present, and no unsafe character is translated.
Value 2 would mean at least one unsafe character is present, and all unsafe characters are translated.
Value 3 would mean at least two unsafe characters are present, and least one not translated, and at least one that is translated.
 
May 29, 2008
521
3
Groton, CT
#4
Or as separate functions which provide counts?
Any of the above would be nice, Charles.

But Steve, the presence of, let's say, an %_amp doesn't mean that it was translated from an unsafe ampersand, so I would reword your description with
Value 2 would mean that at least one character from the translated safe range 0xFF00-0xFF3E (is that right?) is present.
Value 3 would mean that there is at least one unsafe character present and at least one from the translated safe range (no matter how it got there).
 
May 29, 2008
521
3
Groton, CT
#6
And -- just checking -- you want to pass the name of a variable or expression to be evaluated, a la @SAFEEXP, rather than just a string?
Yes, exactly. I was thinking of a single variable as in @SAFEENV, but an expression as in @SAFEEXP would be even more useful. (A version that would take an actual string wouldn't hurt, of course.)
 
May 29, 2008
521
3
Groton, CT
#8
I've uploaded a new build. I haven't done much testing of the new functions, so let me know whether they work as you think they should.
Wow. The descriptions indicate exactly what I think is needed (for my usage), and they look general enough to satisfy any need. I'll be testing shortly.

(later)
Tested (in my one usage, so far). Perfect.

Sample:

> echo %@countsafe["&X%_amp"]
1
> echo %@countunsafe["&X%_amp"]
3
> echo %@len["&X%_amp"]
5

Thanks, Charles.