iainbrighton / PScribo

PowerShell documentation framework
MIT License
231 stars 35 forks source link

Proposed enhancement - check for invalid characters in path #38

Closed it-praktyk closed 7 years ago

it-praktyk commented 7 years ago

I've wrote a module New-OutputObject what is published to the PowerShell Gallery too - link.

As the part of that module I'wrote the function Test-CharsInPath what can be used to parse provided names of files for exported documents (the parameter '-Path' in the function Export-Document) for incorrect chars.

The quote from Test-CharsInPath help is below.

    .DESCRIPTION
    PowerShell function intended to verify if in the string what is the path to file or folder are incorrect chars.
    Exit codes
    - 0 - everything OK
    - 1 - nothing to check
    - 2 - an incorrect char found in the path part
    - 3 - an incorrect char found in the file name part
    - 4 - incorrect chars found in the path part and in the file name part

What do you think about

I see that in about_ToDo that kind of plan for Output/Plugins.

iainbrighton commented 7 years ago

@it-praktyk Checking that the document name is also a valid filename is very worthwhile. If you already have a function that can be used that you're happy to share - I'm all for it 😉. I don't see a need to bundle the whole New-OutputObject module at present?

it-praktyk commented 7 years ago

OK, so I'll prepare a pull request . Probably, initially, I'll add names checking only and maybe I'll mention about possibility to extend names preparing in README (?).

it-praktyk commented 7 years ago

Does the best place to check the Name of document for unsupported chars is the begin section in the Document function?

iainbrighton commented 7 years ago

@it-praktyk Yes - in the New-PScriboDocument method. As document name is used for the output filename, if it's invalid we should error when creating the document/object. Note: thinking ahead we might want to make sure that we cover off invalid Linux characters too?

it-praktyk commented 7 years ago

Today I did first tests the New-OutputObject module on Linux - the module in the current version is not compatible with Linux. I'll try resolve it soon.

iainbrighton commented 7 years ago

@it-praktyk Your New-OutputObject module implementation is not compatible on Linux? I have dome some initial testing and all unit tests are passing for PScribo Core PowerShell 6 Beta 1 and Beta 2 😃.

it-praktyk commented 7 years ago

For the function Test-CharsInPath I stuck now.

it-praktyk commented 7 years ago

@iainbrighton , my New-OutputObject module is compatible with Linux - tested on PowerShell Core v6.0.0-beta4 - the function Test-CharsInPath (what is the subject of #45) too. On next week I'll try find someone who will test in on MacOS and test it on Windows Server Nano.