Is allowing spaces i usernames safe?

Discussion in 'PHP' started by x0x, Mar 21, 2009.

  1. #1
    I don't see why I shouldn't do that?
     
    x0x, Mar 21, 2009 IP
  2. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just url encode it...urlencode($username) and urldecode(). I can help if needed.
     
    NatalicWolf, Mar 21, 2009 IP
  3. x0x

    x0x Well-Known Member

    Messages:
    510
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #3
    It doesn't let me edit the title anymore, it should have said Reload this Page Is allowing spaces in usernames safe?
     
    x0x, Mar 21, 2009 IP
  4. searchingcoder

    searchingcoder Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    in my oppinion it's a safe thing..i can't see any problem in this.On my site i allow spaces in usernames.
    searchingcoder
     
    searchingcoder, Mar 21, 2009 IP
  5. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #5
    Convert all spaces to _ and it'll be as safe as simple abcde string :)
     
    ActiveFrost, Mar 21, 2009 IP
  6. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #6
    There's nothing unsafe about it. The reasons why spaces aren't ordinarily allowed in usernames are mainly historical. The only problem is that sometimes it's harder for people to remember them correctly because most users are so well trained to believe that spaces are not allowed.
     
    SmallPotatoes, Mar 21, 2009 IP
  7. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #7
    Having spaces in the username is OK. However, you might run into problems if you don't encode/decode the URL if it contains the username with the space.

    Peace,
     
    Barti1987, Mar 21, 2009 IP
  8. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #8
    Don't forget that "name" and "name[space]" will not be immediately distinguishable by the average visitor. It would be a shame for "name" to get banned for something "name[space]" did.
     
    joebert, Mar 24, 2009 IP
  9. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I always call trim() on absolutely everything that comes in from the user. Avoids all types of problems like that. In 16 years of web development I have never once encountered a situation where storing leading or trailing spaces in a value entered via an HTML form was desirable or useful.
     
    SmallPotatoes, Mar 24, 2009 IP
  10. Ilyesoft

    Ilyesoft Banned

    Messages:
    164
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    So why many websites don't allow it ?
    Maybe because of database problem ?
     
    Ilyesoft, Mar 25, 2009 IP
  11. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Habit. For 99% of web sites that do not allow it, there is no other reason. Their developers don't allow it because they've seen other developers not allow it.
     
    SmallPotatoes, Mar 25, 2009 IP
  12. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #12
    Lazyness is also a factor, I believe.

    Lots of webpages uses ready-made backbones, just slightly altered to fit the requirements for the webpage. As lots of these frameworks have "quirks" that for some reason makes them incompatible with different DOCTYPEs and such, there are also restrictions to mundane stuff like spaces in usernames and such. It's not really BAD coding, it's just somewhat deprecated coding, and lazyness on the developers using the offered solution without changing anything, but adapting to it instead.
     
    PoPSiCLe, Mar 25, 2009 IP