diff --git a/appveyor.yml b/appveyor.yml index 3adf5b8a..108f1059 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,6 +21,9 @@ install: # However, secure variables are not decoded during Pull Request builds which prevents someone from submitting PR with malicious build script displaying those variables. In more controlled environment through with a trusted team and private GitHub repositories there is an option on General tab of project settings to allow secure variables for PRs. environment: PATH: $(PATH);$(PROGRAMFILES)\dotnet\ + + # https://www.appveyor.com/docs/build-configuration/#secure-variables + # However, secure variables are not decoded during Pull Request builds which prevents someone from submitting PR with malicious build script displaying those variables. In more controlled environment through with a trusted team and private GitHub repositories there is an option on General tab of project settings to allow secure variables for PRs. COVERALLS_REPO_TOKEN: secure: tsTABRbCmdWFLT194XNIrpurerOfjN6cEoxt2RaSUfLmUIgra/+CwuqVkv0sPRop SONAR_TOKEN: @@ -62,6 +65,7 @@ test_script: - cmd: '"OpenCover\tools\OpenCover.Console.exe" -target:dotnet.exe -targetargs:"test test\System.Linq.Dynamic.Core.Tests\System.Linq.Dynamic.Core.Tests.csproj --configuration %CONFIGURATION% --framework netcoreapp1.1 --no-build" -output:coverage.xml -register:user -filter:"+[Microsoft.EntityFrameworkCore.DynamicLinq]* +[System.Linq.Dynamic.Core]* -[*Tests*]*" -nodefaultfilters -returntargetcode -oldstyle' - codecov -f "coverage.xml" - coveralls.net\tools\csmacnz.Coveralls.exe --opencover -i .\coverage.xml + - ps: 'if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { & dotnet sonarscanner end /d:sonar.login="$env:SONAR_TOKEN" }' # Run tests for EntityFramework.DynamicLinq diff --git a/src/System.Linq.Dynamic.Core/Parser/ExpressionParser.cs b/src/System.Linq.Dynamic.Core/Parser/ExpressionParser.cs index ab4bd3c4..89d0af08 100644 --- a/src/System.Linq.Dynamic.Core/Parser/ExpressionParser.cs +++ b/src/System.Linq.Dynamic.Core/Parser/ExpressionParser.cs @@ -755,6 +755,21 @@ Expression ParseStringLiteral() _textParser.ValidateToken(TokenId.StringLiteral); char quote = _textParser.CurrentToken.Text[0]; string s = _textParser.CurrentToken.Text.Substring(1, _textParser.CurrentToken.Text.Length - 2); + int index1 = 0; + while (true) + { + int index2 = s.IndexOf(quote, index1); + if (index2 < 0) + { + break; + } + + if (index2 + 1 < s.Length && s[index2 + 1] == quote) + { + s = s.Remove(index2, 1); + } + index1 = index2 + 1; + } if (quote == '\'') { diff --git a/test/System.Linq.Dynamic.Core.Tests/DynamicExpressionParserTests.cs b/test/System.Linq.Dynamic.Core.Tests/DynamicExpressionParserTests.cs index 93b3bd76..ae033a5b 100644 --- a/test/System.Linq.Dynamic.Core.Tests/DynamicExpressionParserTests.cs +++ b/test/System.Linq.Dynamic.Core.Tests/DynamicExpressionParserTests.cs @@ -440,5 +440,17 @@ public void ParseLambda_CustomMethod() // Assert Check.That(result).IsEqualTo(10); } + + [Fact] + public void ParseLambda_With_InnerStringLiteral() + { + var originalTrueValue = "simple + \"quoted\""; + var doubleQuotedTrueValue = "simple + \"\"quoted\"\""; + var expressionText = $"iif(1>0, \"{doubleQuotedTrueValue}\", \"false\")"; + var lambda = DynamicExpressionParser.ParseLambda(typeof(string), null, expressionText); + var del = lambda.Compile(); + object result = del.DynamicInvoke(String.Empty); + Check.That(result).IsEqualTo(originalTrueValue); + } } }