Re: shell variable security



<snip>
If all you are looking is to grab everything up to the first ; or :
(anything after is deemed invalid) you could use string manipulation.
Test it out as follows:

read name; echo ${name%%+(;|:)*}

It will echo everyting to the first ; or : (omitting the invalid
character and everything after.

This will only work if you have extglob enabled as shopt.

If this does what you want, you can assign the value of your variable
using that string manipulation, hence cutting out the ; or : and
everything after. No testing conditions. If there are other
characters you wish to exclude simply add them in the patter by
separating each with the pipe |.

<snip>
Jacques B.


I re-reading your original request I see that you are looking to
validate if such a character was used. Using my suggestion you could
assign that value to a temp variable and then compare the temp
variable to the variable that contains the full user input. If they
match then the user didn't type any invalid characters as nothing was
truncated from his original input. If they don't match that means
something was truncated hence an invalid character was entered.

Jacques B.

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list



Relevant Pages

  • Re: Understanding simplest HTML page
    ... Even the BBC managed to put invalid ... > technical details of using a particular encoding, ... Bengali and so on using utf-8 ... Mozilla has routines for automatically guessing at character ...
    (comp.infosystems.www.authoring.html)
  • Re: Insert Statement put invalid character data into UTF8 database/column
    ... file managed to get us invalid data into a ... All character data in the DB is UTF8 and this script with insert ... that in some cases the bytes of the UTF8 column ... data, use sqlplus. ...
    (comp.databases.oracle.misc)
  • Re: Invalid Characters in Worksheet Name (International)
    ... Here's the updated code that checks for the wide versions of all invalid ... private string ValidSheetName ... string validSheetName = String.Empty; ... // Character limit on sheet names would be exceeded, ...
    (microsoft.public.excel.programming)
  • Re: Import from Excel .xls problem
    ... For every column in the first record, I got 'Invalid Character.: ... "H"EWLETT PACKARD OFFI' etc. ...
    (comp.databases.paradox)
  • Re: Errno 84
    ... "Invalid or incomplete multibyte or wide character" ... In case of "invalid or incomplete mutibyte or wide character". ... does, what language it's in, post relevant sections of code, etc. ...
    (comp.unix.programmer)