Image name/Path not stripping all illegal chars



  • 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


  • Developer

    Moved and marked as solved.



  • 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.


  • Senior Developer

    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).


  • Senior Developer

    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.


 

340
Online

41.2k
Users

11.6k
Topics

110.7k
Posts

Looks like your connection to FOG Project was lost, please wait while we try to reconnect.