]> granicus.if.org Git - graphviz/commitdiff
Make parsing of vcvarsall.bat output more robust
authorMagnus Jacobsson <magnus.jacobsson@berotec.se>
Sun, 23 Aug 2020 08:25:50 +0000 (10:25 +0200)
committerMagnus Jacobsson <magnus.jacobsson@berotec.se>
Sun, 23 Aug 2020 16:05:03 +0000 (18:05 +0200)
Only consider variable names with alpanumeric characters, underscore
and parentheses. This avoids most problems when parsing output
containing multi-line variable values with arbitrary text.

In GitLab CI, one of the environment variables is CI_COMMIT_MESSAGE. In the commit immediately following this commit there is an URL containing an equal sign that caused the error below:

Set-Content : An object at the specified path
env:\https://docs.microsoft.com/en-us/visualstudio/ide/how-to-configure-projects-to-target-platforms?view does not
exist, or has been filtered by the -Include or -Exclude parameter.
At line:3 char:5
+     Set-Content "env:\$($matches[1])" $matches[2];
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (System.String[]:String[]) [Set-Content], Exception
    + FullyQualifiedErrorId : ItemNotFound,Microsoft.PowerShell.Commands.SetContentCommand

.gitlab-ci.yml

index fd3b345bb10e462787083300fa277c9fcfa9414d..998390b5b5d024dd25de926592925ee7bed9cae2 100644 (file)
@@ -118,7 +118,7 @@ portable-source:
         - cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat`" $TARGET_ARCH && set > %temp%\vcvars.txt";
         - >-
             Get-Content "$env:temp\vcvars.txt" | Foreach-Object {
-              if ($_ -match "^(.*?)=(.*)$") {
+              if ($_ -match "^([A-Za-z0-9_()]*)=(.*)$") {
                 Set-Content "env:\$($matches[1])" $matches[2];
               }
             }