Skip to content

Commit 9198f5b

Browse files
committed
CPP/CSharp/Java/Javascript: Use concat in XMLParent.allCharactersString().
1 parent 26c1397 commit 9198f5b

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

  • cpp/ql/src/semmle/code/cpp
  • csharp/ql/src/semmle/code/csharp
  • javascript/ql/src/semmle/javascript
  • java/ql/src/semmle/code/xml

cpp/ql/src/semmle/code/cpp/XML.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,12 @@ class XMLParent extends @xmlparent {
6767
}
6868

6969
/**
70+
* DEPRECATED: Internal.
71+
*
7072
* Append the character sequences of this XML parent from left to right, separated by a space,
7173
* up to a specified (zero-based) index.
7274
*/
75+
deprecated
7376
string charsSetUpTo(int n) {
7477
(n = 0 and xmlChars(_,result,this,0,_,_)) or
7578
(n > 0 and exists(string chars | xmlChars(_,chars,this,n,_,_) |
@@ -78,10 +81,7 @@ class XMLParent extends @xmlparent {
7881

7982
/** Append all the character sequences of this XML parent from left to right, separated by a space. */
8083
string allCharactersString() {
81-
exists(int n | n = this.getNumberOfCharacterSets() |
82-
(n = 0 and result = "") or
83-
(n > 0 and result = this.charsSetUpTo(n-1))
84-
)
84+
result = concat(string chars, int pos | xmlChars(_, chars, this, pos, _, _) | chars, " " order by pos)
8585
}
8686

8787
/** Gets the text value contained in this XML parent. */

csharp/ql/src/semmle/code/csharp/XML.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,12 @@ class XMLParent extends @xmlparent {
7979
}
8080

8181
/**
82+
* DEPRECATED: Internal.
83+
*
8284
* Append the character sequences of this XML parent from left to right, separated by a space,
8385
* up to a specified (zero-based) index.
8486
*/
87+
deprecated
8588
string charsSetUpTo(int n) {
8689
(n = 0 and xmlChars(_,result,this,0,_,_)) or
8790
(n > 0 and exists(string chars | xmlChars(_,chars,this,n,_,_) |
@@ -90,10 +93,7 @@ class XMLParent extends @xmlparent {
9093

9194
/** Append all the character sequences of this XML parent from left to right, separated by a space. */
9295
string allCharactersString() {
93-
exists(int n | n = this.getNumberOfCharacterSets() |
94-
(n = 0 and result = "") or
95-
(n > 0 and result = this.charsSetUpTo(n-1))
96-
)
96+
result = concat(string chars, int pos | xmlChars(_, chars, this, pos, _, _) | chars, " " order by pos)
9797
}
9898

9999
/** Gets the text value contained in this XML parent. */

java/ql/src/semmle/code/xml/XML.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,12 @@ class XMLParent extends @xmlparent {
7070
}
7171

7272
/**
73+
* DEPRECATED: Internal.
74+
*
7375
* Append the character sequences of this XML parent from left to right, separated by a space,
7476
* up to a specified (zero-based) index.
7577
*/
78+
deprecated
7679
string charsSetUpTo(int n) {
7780
n = 0 and xmlChars(_,result,this,0,_,_)
7881
or
@@ -84,10 +87,7 @@ class XMLParent extends @xmlparent {
8487

8588
/** Append all the character sequences of this XML parent from left to right, separated by a space. */
8689
string allCharactersString() {
87-
exists(int n | n = this.getNumberOfCharacterSets() |
88-
(n = 0 and result = "") or
89-
(n > 0 and result = this.charsSetUpTo(n-1))
90-
)
90+
result = concat(string chars, int pos | xmlChars(_, chars, this, pos, _, _) | chars, " " order by pos)
9191
}
9292

9393
/** Gets the text value contained in this XML parent. */

javascript/ql/src/semmle/javascript/XML.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,12 @@ class XMLParent extends @xmlparent {
7070
}
7171

7272
/**
73+
* DEPRECATED: Internal.
74+
*
7375
* Append the character sequences of this XML parent from left to right, separated by a space,
7476
* up to a specified (zero-based) index.
7577
*/
78+
deprecated
7679
string charsSetUpTo(int n) {
7780
(n = 0 and xmlChars(_,result,this,0,_,_)) or
7881
(n > 0 and exists(string chars | xmlChars(_,chars,this,n,_,_) |
@@ -81,10 +84,7 @@ class XMLParent extends @xmlparent {
8184

8285
/** Append all the character sequences of this XML parent from left to right, separated by a space. */
8386
string allCharactersString() {
84-
exists(int n | n = this.getNumberOfCharacterSets() |
85-
(n = 0 and result = "") or
86-
(n > 0 and result = this.charsSetUpTo(n-1))
87-
)
87+
result = concat(string chars, int pos | xmlChars(_, chars, this, pos, _, _) | chars, " " order by pos)
8888
}
8989

9090
/** Gets the text value contained in this XML parent. */

0 commit comments

Comments
 (0)