REGEX (Not allowing file extenstions) or the dot

Discussion in 'Perl Misc' started by Guest, Oct 4, 2003.

  1. Guest

    Guest Guest

    REGULAR EXPRESSION

    PROGRAM: Quake2
    CODE: C+

    REGULAR EXPRESSION REQUEST EXPLINATION

    I am running a quake2 server with a program that has the capabilities to disable (client-side) commands or any
    part of a string pass on to the server. So,
    anyone who connects to my game server and tries to issue a command that is on the "command BAN list" will not
    work. The good news is, is that the programmer intelligently included the ability to match regular expression
    matching. Now what I want to do is simple. I want to prevent someone typing any type of file extention. On
    the latter part of the filename after the '.' and including the '.' dot. I am allowing people to change
    maps via LRCON from the program dll Q2admin. I have a banlist.txt file were I can place any regular expresssion match,
    and if client tries to send the command to my gaming server and is checked inside this banlist.txt file,
    any matches in this banlist.txt file command will be ignored.

    This is great because there is one fucked up flaw in the mod I'm running. It could also be Quake2's code's fault.
    When someone has regular rcon, or lrcon, and from WAN or LAN side, if the include the *.bsp extention on to
    the command it crashes the server. Also, if they type a name of a map that DOES NOT EXIST in the /maps
    direcotry, EX., abcd.bsp, and anyone tries to change to this map it crashes the server.

    All I want to do is prevent, BAN the adding of the extenstion "*.bsp", Or better yet, is to totally
    make the server ignore ANY FILE EXTENTION ".*" including the '.' as well. I only want them to be allowed
    to type in the filename.

    They can type

    mapname

    all they want, but I do not want to allow

    mapname.bsp or
    mapname.123 or
    mapname.* or
    mapname.

    IMPORTANT: here is the entire command the clients have to type in order to send a command to the server
    to change a map:

    lrcon map map q2dm1

    EXPLINATION: The 'lrocn' part is allowed. the first 'map', is allowed, the second 'map', is allowed,
    the mapname 'q2dm1' is allowed. But what is not allowed is for someone to add a dot '.' after the
    mapname q2dm1 like so "q2dm1." nor what is not allowed is to add any type of extention what so ever
    like so "q2dm1.bsp" or "q2dm1.123" or "q2dm1.1Abcde" etc..

    What regular expression do need to put into the BANLIST.TXT file to make the server ignore
    commands sent to my server with a file extension attached to the mapname?

    Here are the only REGEX examples in the banlist.txt the author gave me, or better yet here is the complete
    BANLIST or Q2adminDisable.txt file, same thing.

    __COPY OF banlist.txt file_____________________________________

    ;
    ;Disable client commands.
    ;
    ;This lists all the cleint mod commands that will be disabled
    ;
    ;The file q2admindisable.txt is read from the quake2 directory and the mod
    ;directory. This allows server admin's to setup disabled commands as
    ;global and mod specific as well.
    ;
    ;The format for q2admindisable.txt is as follows:
    ;
    ;Lines beginning with a ';' are comments.
    ;
    ;disable command format:
    ;<disabletype><command to disable>
    ;
    ; <floodtype> can be one of three values:
    ; 'EX:' Exact match.
    ; 'SW:' Starts with match.
    ; 'RE:' Regular Expression match.
    ;
    ;e.g.
    ;SW:say_team
    ;EX:team
    ;RE:^say.*
    ;
    ; Note that internal commands to quake2 can't be monitored as
    ; mod's don't see these client commands. e.g. name, cl_maxfps, rate, etc
    ;
    ;There is a limit of 1024 disable commands that can be setup.
    ;
    _________________________________________

    NOw what I do want to allow is for the client to do this:

    lrcon map map q2dm1

    I DO NOT WANT TO ALLOW THIS: ".bsp" QUAKE SERVER ONLY NEEDS THE MAP NAME WHICH IS THE NAME OF THE FILE AND
    NOT THE '.' NOR THE 'BSP'. I WANT TO TOTALLY BAN, ".BSP" part of the client's command sent to the server.

    lrcon map map q2dm1.bsp

    anyhelp with this is very much appreciated.

    vynum
    Guest, Oct 4, 2003
    #1
    1. Advertising

  2. <> wrote:

    > This is great because there is one fucked up flaw



    This is a family newsgroup.

    *plonk*


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Oct 4, 2003
    #2
    1. Advertising

  3. wrote:
    > ;RE:^say.*


    > I DO NOT WANT TO ALLOW THIS: ".bsp" QUAKE SERVER ONLY NEEDS THE MAP NAME WHICH IS THE NAME OF THE FILE AND
    > NOT THE '.' NOR THE 'BSP'. I WANT TO TOTALLY BAN, ".BSP" part of the client's command sent to the server.


    > lrcon map map q2dm1.bsp


    The question I have is whether you have any command where a period
    should appear. If you don't, then just ban all periods. The problem is
    that periods are usually special in regular expressions, and I can only
    guess that this module and perl use similar syntax.

    RE:\. # Ban any command with a period.

    If that's too limiting, then this (might) ban anything starting with
    lrcon that has a period elsewhere on the line.

    RE:^lrcon.*\.

    Again, syntax issues for RE are very dependent on what engine is in
    use. Hopefully a backslash escapes the period here, but it might not.

    It is possible that
    RE:^lrcon.*[.]
    would work if the above did not..

    --
    Darren Dunham
    Unix System Administrator Taos - The SysAdmin Company
    Got some Dr Pepper? San Francisco, CA bay area
    < This line left intentionally blank to confuse you. >
    Darren Dunham, Oct 4, 2003
    #3
  4. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    <> wrote in
    news:dcnfb.5595$:

    > REGULAR EXPRESSION
    >
    > PROGRAM: Quake2
    > CODE: C+

    ....
    > anyhelp with this is very much appreciated.
    >
    > vynum


    Does your problem have anything at all to do with Perl? Not so far as I
    could tell.

    - --
    Eric
    $_ = reverse sort $ /. r , qw p ekca lre uJ reh
    ts p , map $ _. $ " , qw e p h tona e and print

    -----BEGIN PGP SIGNATURE-----
    Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

    iQA/AwUBP34XqWPeouIeTNHoEQIS+gCg0lvKYbOuis6TbMDRb8yqBKmXPFUAoPyL
    hZbmPqi53Ug26MOdKb2HIYkA
    =bGcP
    -----END PGP SIGNATURE-----
    Eric J. Roode, Oct 4, 2003
    #4
  5. Guest

    sts Guest

    Yes as a matter of fact it does. I am in the proecess of compiling PERL into
    Quake to help with web statistical reporting of the server
    and of games.

    "Eric J. Roode" <> wrote in message
    news:Xns9409D2CECE05Fsdn.comcast@206.127.4.25...
    > -----BEGIN PGP SIGNED MESSAGE-----
    > Hash: SHA1
    >
    > <> wrote in
    > news:dcnfb.5595$:
    >
    > > REGULAR EXPRESSION
    > >
    > > PROGRAM: Quake2
    > > CODE: C+

    > ...
    > > anyhelp with this is very much appreciated.
    > >
    > > vynum

    >
    > Does your problem have anything at all to do with Perl? Not so far as I
    > could tell.
    >
    > - --
    > Eric
    > $_ = reverse sort $ /. r , qw p ekca lre uJ reh
    > ts p , map $ _. $ " , qw e p h tona e and print
    >
    > -----BEGIN PGP SIGNATURE-----
    > Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
    >
    > iQA/AwUBP34XqWPeouIeTNHoEQIS+gCg0lvKYbOuis6TbMDRb8yqBKmXPFUAoPyL
    > hZbmPqi53Ug26MOdKb2HIYkA
    > =bGcP
    > -----END PGP SIGNATURE-----
    sts, Oct 4, 2003
    #5
  6. Guest

    sts Guest

    "Darren Dunham" <> wrote in message
    news:DOnfb.270$%...
    > wrote:
    > > ;RE:^say.*

    >
    > > I DO NOT WANT TO ALLOW THIS: ".bsp" QUAKE SERVER ONLY NEEDS THE MAP NAME

    WHICH IS THE NAME OF THE FILE AND
    > > NOT THE '.' NOR THE 'BSP'. I WANT TO TOTALLY BAN, ".BSP" part of the

    client's command sent to the server.
    >
    > > lrcon map map q2dm1.bsp

    >
    > The question I have is whether you have any command where a period
    > should appear.


    No. Only the filename of the map without any extenstion or period attached
    to the string.


    > If you don't, then just ban all periods.

    This is almost exactly what I want to do. I want to ban or should I say
    ignore by regular expression , the period, and anything that follows after
    the period.
    The only thing I want allowed is, [a-z/A-Z] and all numbers 1 thru 0's are
    allowed. Another words, at this point, guys who connect to play the game
    are allowed to pass any string command, EXECEPT in this very special
    scenerio were lrcon is used.

    Maybe I should explain what exactly is taking place. John Doe connects and
    types the following:

    lrcon map map q2dm1

    I will break the above down.

    lrcon = tells the quake2admin .dll that an rcon is used and the dll is now
    wating for what command?

    map = map tells the quake2admin dll that the "map" command to change maps is
    to be used.

    map = the last "map" is the public password. Now the quake2admin is now
    waiting for one more peice of information. What map should it change to?
    this is were I want the regular expresion to start filtering , if
    you will, what is allowed and what should be ignored.

    So, this is going to be kinda of a weird way to explain it but once you see
    it I think you will get the idea.

    Everything outside the ( ) is allowed. Anything within the parenthasis
    should be disallowed, ignored.

    lrcon map map q2dm1(.bsp) The dot and the file extention or ANY extension
    should be banned by regular expression. q2dm1 is just a name of a map.


    The problem is
    > that periods are usually special in regular expressions, and I can only
    > guess that this module and perl use similar syntax.
    >
    > RE:\. # Ban any command with a period.
    >
    > If that's too limiting, then this (might) ban anything starting with
    > lrcon that has a period elsewhere on the line.
    >
    > RE:^lrcon.*\.
    >
    > Again, syntax issues for RE are very dependent on what engine is in
    > use. Hopefully a backslash escapes the period here, but it might not.
    >
    > It is possible that
    > RE:^lrcon.*[.]
    > would work if the above did not..
    >

    Does the above mean that they can type anything starting with lrcon and
    anything there after, but if a dot is used any were inside the string
    oranything after the dot
    is disallowed? IF so, then this is exactly what I want.
    > --
    > Darren Dunham
    > Unix System Administrator Taos - The SysAdmin Company
    > Got some Dr Pepper? San Francisco, CA bay area
    > < This line left intentionally blank to confuse you. >
    sts, Oct 4, 2003
    #6
  7. sts <> wrote:

    > Yes as a matter of fact it does.



    _what_ does?


    > I am in the proecess of compiling PERL into
    > Quake



    Then to discard any part of a filename after a dot character:

    $filename =~ s/\..*//s;



    [snip TOFU]


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Oct 4, 2003
    #7
  8. wrote:
    > REGULAR EXPRESSION
    >
    > PROGRAM: Quake2
    > CODE: C+
    >

    [long convoluted explanation of some syntax snipped]

    You may not realize it as such but to me this sounds like you want to write
    a parser and context checker for a language that you created.
    And you are not even sure how the language works.

    My advice would be to
    - first define a formal language, just as you would define any programming
    language
    - then write a parser for it, starting with lexical and syntax analysis
    - then your test for the file extensions or not file extensions will become
    just one simple context condition among many others. And it will be easy to
    test because you know that at that point in the tree you need to test for
    exactly that condition and nothing else and you don't need to test for that
    condition anywhere else, either.

    As this is not really related to Perl you may get more detailed advice in a
    NG that actually deals with artificial languages and parsing, e.g a compiler
    construction NG.

    jue
    Jürgen Exner, Oct 4, 2003
    #8
  9. Guest

    sts Guest

    Darren,

    I just want to say thankyou for responding. You helped me solve my problem.
    One of the REGEX that you gave me worked.

    RE:^lrcon.*[.] # This one worked.

    RE:^lrcon.*\. # This did not work.

    RE:\. # I didn't try this one because the first one worked.

    I was just wondering tho out of curiosity, How would I allow the period
    inside a string but only Disallow certain letters & numbers in
    a particlular sequence. Say I only wanted to disallow cetain extension only
    like:

    DISALLOW THE FOLLOWING BUT ACCEPT ANYTHING ELSE:

    bsp
    123
    AdF
    1A2

    Again this is now allowing the '.' to be in the string but doing an Exact
    Match for the extension.

    Thank you

    sts



    "Darren Dunham" <> wrote in message
    news:DOnfb.270$%...
    > wrote:
    > > ;RE:^say.*

    >
    > > I DO NOT WANT TO ALLOW THIS: ".bsp" QUAKE SERVER ONLY NEEDS THE MAP NAME

    WHICH IS THE NAME OF THE FILE AND
    > > NOT THE '.' NOR THE 'BSP'. I WANT TO TOTALLY BAN, ".BSP" part of the

    client's command sent to the server.
    >
    > > lrcon map map q2dm1.bsp

    >
    > The question I have is whether you have any command where a period
    > should appear. If you don't, then just ban all periods. The problem is
    > that periods are usually special in regular expressions, and I can only
    > guess that this module and perl use similar syntax.
    >
    > RE:\. # Ban any command with a period.
    >
    > If that's too limiting, then this (might) ban anything starting with
    > lrcon that has a period elsewhere on the line.
    >
    > RE:^lrcon.*\.
    >
    > Again, syntax issues for RE are very dependent on what engine is in
    > use. Hopefully a backslash escapes the period here, but it might not.
    >
    > It is possible that
    > RE:^lrcon.*[.]
    > would work if the above did not..
    >
    > --
    > Darren Dunham
    > Unix System Administrator Taos - The SysAdmin Company
    > Got some Dr Pepper? San Francisco, CA bay area
    > < This line left intentionally blank to confuse you. >
    sts, Oct 5, 2003
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael Boocher via JavaKB.com
    Replies:
    8
    Views:
    475
    John McGrath
    May 30, 2005
  2. Samuël van Laere

    To dot or not to dot?

    Samuël van Laere, Oct 16, 2003, in forum: HTML
    Replies:
    8
    Views:
    423
    Samuël van Laere
    Oct 16, 2003
  3. Christopher M. Lusardi

    volatile struct in dot h vs dot c

    Christopher M. Lusardi, May 11, 2004, in forum: C Programming
    Replies:
    3
    Views:
    473
    Peter Shaggy Haywood
    May 15, 2004
  4. whit
    Replies:
    1
    Views:
    603
    James Kanze
    Mar 19, 2009
  5. Replies:
    6
    Views:
    244
    Thomas 'PointedEars' Lahn
    Dec 12, 2005
Loading...

Share This Page