Skip to content

Commit 12ebfa6

Browse files
committed
Change join order of Property/Name matching
1 parent 07aad61 commit 12ebfa6

File tree

1 file changed

+11
-6
lines changed
  • csharp/ql/lib/semmle/code/csharp/frameworks/microsoft/aspnetcore

1 file changed

+11
-6
lines changed

csharp/ql/lib/semmle/code/csharp/frameworks/microsoft/aspnetcore/Components.qll

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,26 @@ class MicrosoftAspNetCoreComponentsComponent extends Class {
8888
*
8989
* An example of a route parameter is `@page "/counter/{id:int}/{other?}/{*rest}"`, from this we're getting the `id`, `other` and `rest` parameters.
9090
*/
91+
pragma[nomagic]
9192
private string getARouteParameter() {
92-
result = this.getRouteAttributeUrl().splitAt("{").regexpCapture("\\*?([^:?}]+)[:?}](.*)", 1)
93+
exists(string s |
94+
s = this.getRouteAttributeUrl().splitAt("{").regexpCapture("\\*?([^:?}]+)[:?}](.*)", 1) and
95+
result = s.toLowerCase()
96+
)
9397
}
9498

9599
/** Gets a property attributed with `[Parameter]` attribute. */
96-
Property getAParameterProperty() {
100+
pragma[nomagic]
101+
private Property getAParameterProperty(string name) {
97102
result = this.getAProperty() and
98-
result.getAnAttribute() instanceof MicrosoftAspNetCoreComponentsParameterAttribute
103+
result.getAnAttribute() instanceof MicrosoftAspNetCoreComponentsParameterAttribute and
104+
name = result.getName().toLowerCase()
99105
}
100106

101107
/** Gets a property whose value is populated from route parameters. */
102108
Property getARouteParameterProperty() {
103-
result = this.getAParameterProperty() and
104-
exists(string urlParamName | urlParamName = this.getARouteParameter() |
105-
result.getName().toLowerCase() = urlParamName.toLowerCase()
109+
exists(string name | name = this.getARouteParameter() |
110+
result = this.getAParameterProperty(name)
106111
)
107112
}
108113
}

0 commit comments

Comments
 (0)