Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Trim username

    Scheduled Pinned Locked Moved Captive Portal
    9 Posts 5 Posters 1.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      heper
      last edited by

      @jimp @johnpoz @Gertjan

      is there any reason you can think of, why the username post-var of CP isn't trimmed?

      I'm running CP with AD/radius & highschool students are entering leading or trailing spaces in their usernames. this results in 'invalid credentials'.
      ==> i get the complaint, have to browse the radius logs to find out why & it's almost always a whitespace at the beginning or end of the username.

      If nobody can think of a reason why trim shouldn't be used, then i'll (attempt to) create a PR.
      i guess it would only take a few modifications around here:
      https://github.com/pfsense/pfsense/blob/master/src/usr/local/captiveportal/index.php#L185

      $user = trim($_POST['auth_user']);   //same for auth_user2
      

      at first glance,i think code change above would probably suffice.

      looking forward to your feedback

      GertjanG 1 Reply Last reply Reply Quote 0
      • GertjanG
        Gertjan @heper
        last edited by Gertjan

        @heper said in Trim username:

        is there any reason you can think of, why the username post-var of CP isn't trimmed?

        Yes.
        It's very important that people learn, if needed, the hard way, that on electronic system white spaces are characters.
        Added to that : double clicking on a word (with the mouse) will select only that word excluding white space characters (and often other signs like dashes on the outside of the word'). It's important to know that what you copy is really what you want to copy (and paste).

        The subject is know, and people that are subjected to those "login screen that won't pass them through" will find this issue with most Internet sites.

        And a white space can be a valid character in a password.

        But ...

        @heper said in Trim username:

        $user = trim($_POST['auth_user']); //same for auth_user2

        of course you are right. I even did exactly the same thing, some years ago. Not because I discovered a bug in pfSense, but I discovered that there are people that write email addresses in all capitals (not strictly wrong, simply not done), write SMS's even even letters (real snail mail !!!) in all capitals (no kidding)..
        These are the same people that just discovered the use of "select and copy" by using the mouse, left click pressed.
        I decided that that "issue" wasn't mine and started to help them, by removing the trim() ...

        No "help me" PM's please. Use the forum, the community will thank you.
        Edit : and where are the logs ??

        1 Reply Last reply Reply Quote 0
        • jimpJ
          jimp Rebel Alliance Developer Netgate
          last edited by

          No reason I know of to not trim the username there. I'm not aware of any system where a space would be significant before or after the username, and IIRC LDAP will ignore the spaces in that context anyhow.

          Open an issue and submit a PR and we can look it over. There may be some other reason I'm forgetting.

          Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

          Need help fast? Netgate Global Support!

          Do not Chat/PM for help!

          1 Reply Last reply Reply Quote 0
          • H
            heper
            last edited by

            issue #9274 created

            1 Reply Last reply Reply Quote 0
            • V
              vhs
              last edited by

              @heper
              I think it's only logical to have a trim( .. ) there.
              After all, there is a trim applied to auth_voucher POST-variable, a few lines above the one you mentioned.
              https://github.com/pfsense/pfsense/blob/master/src/usr/local/captiveportal/index.php#L159

              1 Reply Last reply Reply Quote 0
              • F
                free4 Rebel Alliance
                last edited by

                hi @heper
                could you have a look to the comment on your pull request on github ? https://github.com/pfsense/pfsense/pull/4037#discussion_r250025108

                H 1 Reply Last reply Reply Quote 0
                • H
                  heper @free4
                  last edited by

                  @free4 you might have a point but It's clear the devs have better things to do then look at this minor detail.

                  Whoever of the staff that finds the time to look at the pr, can change it as they see fit. ๐Ÿ˜ƒ

                  1 Reply Last reply Reply Quote 0
                  • jimpJ
                    jimp Rebel Alliance Developer Netgate
                    last edited by

                    The point of a PR is so that devs don't have to make the changes necessary for the submitted code to work properly. The PR needs to be fixed, then merged. Not the other way around.

                    Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

                    Need help fast? Netgate Global Support!

                    Do not Chat/PM for help!

                    H 1 Reply Last reply Reply Quote 0
                    • H
                      heper @jimp
                      last edited by

                      I think everyone can agree that pr's should save time. Making comments on this forum uses valuable time. Probably more time then it would take a skilled coder to fix a couple of characters of code in some crappy pr that a random amateur created

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.