Re: shell variable security

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



<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
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux