Skip to content

Commit d13ef5e

Browse files
committed
BindingStringParser: Match previous behaviour
- Consider all tokens beginning at the same location as eligible to be the next token. - Implement strictContains to reflect previous behaviour.
1 parent ed87aa9 commit d13ef5e

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

javascript/frameworks/ui5/lib/advanced_security/javascript/frameworks/ui5/BindingStringParser.qll

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,13 @@ module BindingStringParser<BindingStringReaderSig BindingStringReader> {
424424
)
425425
}
426426

427+
/**
428+
* The token `t` is completely contained within this outer token.
429+
*/
430+
predicate strictContains(Token t) {
431+
this.contains(t) and t.getBegin() > this.getBegin() and t.getEnd() < this.getEnd()
432+
}
433+
427434
stdlib::Location getLocation() { result = getReader().getLocation() }
428435
}
429436

@@ -435,12 +442,7 @@ module BindingStringParser<BindingStringReaderSig BindingStringReader> {
435442
* `position + count(tokens_with_current_position)`.
436443
*/
437444
private predicate tokenOrdering(BindingStringReader reader, Token t, int position) {
438-
t =
439-
rank[position](Token token |
440-
token.getReader() = reader
441-
|
442-
token order by token.getBegin(), token.getEnd()
443-
)
445+
t = rank[position](Token token | token.getReader() = reader | token order by token.getBegin())
444446
}
445447

446448
/**
@@ -684,15 +686,15 @@ module BindingStringParser<BindingStringReaderSig BindingStringReader> {
684686
private newtype TValue =
685687
MkNumber(float n, Token source) {
686688
exists(NumberToken t | t.getValue().toFloat() = n and source = t |
687-
not any(StringToken str).contains(t) and
688-
not any(NameToken name).contains(t)
689+
not any(StringToken str).strictContains(t) and
690+
not any(NameToken name).strictContains(t)
689691
)
690692
} or
691693
MkString(string s, Token source) {
692694
exists(StringToken t |
693695
t.(Token).getValue() = s and
694696
t = source and
695-
not any(NameToken nameToken).contains(t)
697+
not any(NameToken nameToken).strictContains(t)
696698
)
697699
} or
698700
MkObject(MemberList members, Token source) {
@@ -721,27 +723,27 @@ module BindingStringParser<BindingStringReaderSig BindingStringReader> {
721723
} or
722724
MkTrue(Token source) {
723725
exists(TrueToken t |
724-
not any(StringToken str).contains(t) and
725-
not any(NameToken nameToken).contains(t) and
726+
not any(StringToken str).strictContains(t) and
727+
not any(NameToken nameToken).strictContains(t) and
726728
source = t
727729
)
728730
} or
729731
MkFalse(Token source) {
730732
exists(FalseToken t |
731-
not any(StringToken str).contains(t) and
732-
not any(NameToken nameToken).contains(t) and
733+
not any(StringToken str).strictContains(t) and
734+
not any(NameToken nameToken).strictContains(t) and
733735
source = t
734736
)
735737
} or
736738
MkNull(Token source) {
737739
exists(NullToken t |
738-
not any(StringToken str).contains(t) and
739-
not any(NameToken nameToken).contains(t) and
740+
not any(StringToken str).strictContains(t) and
741+
not any(NameToken nameToken).strictContains(t) and
740742
source = t
741743
)
742744
} or
743745
MkName(Token source) {
744-
exists(NameToken t | not any(StringToken str).contains(t) and source = t)
746+
exists(NameToken t | not any(StringToken str).strictContains(t) and source = t)
745747
} or
746748
MkIdent(Token source) {
747749
exists(IdentToken t | source = t and getNextSkippingWhitespace(t) instanceof ColonToken)

0 commit comments

Comments
 (0)