Skip to content
4 changes: 4 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions src/System.Linq.Dynamic.Core/Parser/ExpressionParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use {} in this new code. Example:

if (index2 < 0)
{
    break;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! I'm done.

{
break;
}

if (index2 + 1 < s.Length && s[index2 + 1] == quote)
{
s = s.Remove(index2, 1);
}
index1 = index2 + 1;
}

if (quote == '\'')
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}