variable replacement cannot handle embedded newlines

Issue #27 on hold
Former user created an issue

In the following expression: #[var cs = $(cs.Replace(<PROJECT_TAGS>, "#[var projectRev]") if the variable projectRev has newlines, the command will fail. This is true with or without quotes.

Comments (7)

  1. Denis Kuzmin repo owner

    if it's you - Issue #26 well...

     $(cs.Replace(...
    

    this for MSBuild core, so yes the newline symbols is not allowed and will be fail

    I think need an additional component for work with special symbols... need to think

    stay in touch!

  2. Denis Kuzmin repo owner

    ok, I checked variant for MSBuild

    #[var cs = line1
    line2]
    
    #[var cs = $(cs.Replace("\r\n", ""))]
    

    or with different combination CR/LF

    #[var cs = $(cs.Replace("\r", "").Replace("\n", ""))]
    
    result: line1line2
    

    so, we can use the Replace() function of the MSBuild core for any result from SBE-Scripts core

    but, v0.9 is not contains handler of symbols \r\n for the MSBuild properties

    this should be implemented is coming soon, and I think to include this in planned v0.10

    you can watch this ticket about progress of this implementation..

    Please remeber: bitbucket.org allows anonymous issue creation, but for new comments you should be authorized for this tracker

  3. Denis Kuzmin repo owner

    implemented with 4e6b15e and should be included in v0.10


    now, if you have a multiline value in your variable projectRev, for example:

    #[var cs = Version is a %ver% !] 
    
    #[var projectRev = v1.2
    debug 
    rev321]
    

    you should strip this with Replace on any compatible sequence, e.g.

    #[var projectRev = $(projectRev.Replace("\r\n", " :: "))]
    #[var cs = $(cs.Replace("%ver%", "#[var projectRev]"))]
    

    or as variant:

    #[var cs = $(cs.Replace("%ver%", $(projectRev.Replace("\r\n", " :: "))))]
    

    and similar...

    note:

    • use the escaping \\r \\n if need this
    • use the \x00 - \xFF for other char by code

    as result in variable cs we have:

    Version is a v1.2 :: debug  :: rev321 !
    
  4. Log in to comment