Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 47c1fc7

Browse files
author
Max Schaefer
committed
C++/Python: Fix XMLFile.getPath and XMLFile.getFolder.
Previously, the former returned the file's stem (that is, basename without extension), and the latter never held.
1 parent bf30f9c commit 47c1fc7

2 files changed

Lines changed: 9 additions & 13 deletions

File tree

  • cpp/ql/src/semmle/code/cpp
  • python/ql/src/semmle/python/xml

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,13 @@ class XMLFile extends XMLParent, File {
115115
override string toString() { result = XMLParent.super.toString() }
116116

117117
/** Gets the name of this XML file. */
118-
override string getName() { files(this, result, _, _, _) }
118+
override string getName() { result = File.super.getAbsolutePath() }
119119

120120
/** Gets the path of this XML file. */
121-
string getPath() { files(this, _, result, _, _) }
121+
string getPath() { result = getAbsolutePath() }
122122

123123
/** Gets the path of the folder that contains this XML file. */
124-
string getFolder() {
125-
result = this.getPath().substring(0, this.getPath().length() - this.getName().length())
126-
}
124+
string getFolder() { result = getParentContainer().getAbsolutePath() }
127125

128126
/** Gets the encoding of this XML file. */
129127
string getEncoding() { xmlEncoding(this, result) }

python/ql/src/semmle/python/xml/XML.qll

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,14 @@ class XMLFile extends XMLParent, File {
114114
/** Gets a printable representation of this XML file. */
115115
override string toString() { result = XMLParent.super.toString() }
116116

117-
/** The name of this XML file. */
118-
override string getName() { files(this, result, _, _, _) }
117+
/** Gets the name of this XML file. */
118+
override string getName() { result = File.super.getAbsolutePath() }
119119

120-
/** The path of this XML file. */
121-
string getPath() { files(this, _, result, _, _) }
120+
/** Gets the path of this XML file. */
121+
string getPath() { result = getAbsolutePath() }
122122

123-
/** The path of the folder that contains this XML file. */
124-
string getFolder() {
125-
result = this.getPath().substring(0, this.getPath().length() - this.getName().length())
126-
}
123+
/** Gets the path of the folder that contains this XML file. */
124+
string getFolder() { result = getParentContainer().getAbsolutePath() }
127125

128126
/** Gets the encoding of this XML file. */
129127
string getEncoding() { xmlEncoding(this, result) }

0 commit comments

Comments
 (0)