• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Image name/Path not stripping all illegal chars

    Scheduled Pinned Locked Moved Solved
    FOG Problems
    3
    5
    555
    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.
    • andyb2000A
      andyb2000
      last edited by

      This appears a fairly simple one, when creating a new image, image name (iName) takes any characters, which then does a regular expression replace to fill in the iFile input box with the Image Path to be created.
      It doesn’t escape/remove all illegal characters, one such character is the forward-slash which then causes filesystem issues during the FTP rename component.

      Tested using Image Name of “MyTest-25/01/18” which then gets the image path filled out to /images/mytest-25/01/18
      When image is captured the process fails at the FTP segment, raw ftp logs show the rename failing:

      Thu Jan 25 15:27:40 2018 [pid 28283] [fog] FTP command: Client "172.16.4.1", "RNFR /images/dev/18a905f6e4ae"
      Thu Jan 25 15:27:40 2018 [pid 28283] [fog] FTP response: Client "172.16.4.1", "350 Ready for RNTO."
      Thu Jan 25 15:27:40 2018 [pid 28283] [fog] FTP command: Client "172.16.4.1", "RNTO /images/mytest-25/01/18"
      Thu Jan 25 15:27:40 2018 [pid 28283] [fog] FTP response: Client "172.16.4.1", "550 Rename failed."
      

      (Obviously due to the forward slash being a directory command in Linux).

      Code in question:
      fog/management/js/fog/fog.image.js

          $('#iName').on('change keyup',function(e) {
              var start = this.selectionStart,
                  end = this.selectionEnd;
              if (typeof iFileVal === 'undefined') return;
              if (iFileVal.length == 0) $('#iFile').val(this.value.replace(/[^\w+\/\.-]/g,''));
              this.setSelectionRange(start,end);
              e.preventDefault();
      

      I’m out of time today, but will try and spot the error in the regex as it does appear to have it in the replace values (/)

      Regards,
      Andy

      Regards,
      Andy
      http://www.thebmwz3.co.uk/
      https://github.com/andyb2000

      1 Reply Last reply Reply Quote 0
      • Tom ElliottT
        Tom Elliott
        last edited by

        This isn’t really a bug, per-say.

        People might actually want to store there images in sub directories. I don’t think the problem with ftp is because the / is a directory command, but rather that particular directory path does not exist and ftp can’t do the equivalent of mkdir -p.

        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

        1 Reply Last reply Reply Quote 0
        • Tom ElliottT
          Tom Elliott
          last edited by

          And to help with the “where it’s going wrong” is it’s looking to replace when the length of the field is 0 (eg nothing typed in).

          Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

          Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

          Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

          1 Reply Last reply Reply Quote 0
          • andyb2000A
            andyb2000
            last edited by

            Ah, thanks for the clarification @Tom-Elliott that makes sense, I just had some users complaining as they weren’t particularly linux-savvy trying to capture, not realising the significance of the forward slash.
            Thank you, I’ll advise them.

            Regards,
            Andy
            http://www.thebmwz3.co.uk/
            https://github.com/andyb2000

            1 Reply Last reply Reply Quote 0
            • S
              Sebastian Roth Moderator
              last edited by

              Moved and marked as solved.

              Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

              Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post

              170

              Online

              12.0k

              Users

              17.3k

              Topics

              155.2k

              Posts
              Copyright © 2012-2024 FOG Project