Skip to content

Commit 01d3b0b

Browse files
committed
add check to make sure preceding slash not used w/ getChild
1 parent 05b2ed6 commit 01d3b0b

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

core/src/processing/data/XML.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ public XML getChild(int index) {
355355
* @return the first matching element
356356
*/
357357
public XML getChild(String name) {
358+
if (name.length() > 0 && name.charAt(0) == '/') {
359+
throw new IllegalArgumentException("getChild() should not begin with a slash");
360+
}
358361
if (name.indexOf('/') != -1) {
359362
return getChildRecursive(PApplet.split(name, '/'), 0);
360363
}
@@ -413,6 +416,9 @@ protected XML getChildRecursive(String[] items, int offset) {
413416
* @author processing.org
414417
*/
415418
public XML[] getChildren(String name) {
419+
if (name.length() > 0 && name.charAt(0) == '/') {
420+
throw new IllegalArgumentException("getChildren() should not begin with a slash");
421+
}
416422
if (name.indexOf('/') != -1) {
417423
return getChildrenRecursive(PApplet.split(name, '/'), 0);
418424
}

core/todo.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ o 2) we keep getFloat() like it is, and add getFloatContent(), etc.
155155
o 3) we deprecate our nice short getFloat/getInt/etc and go with
156156
o getXxxxAttribute() and getXxxxContent() methods.
157157
X not gonna do getFloatContent() since it's not really any shorter
158-
159-
_ beginning slash in getChild() threw an NPE
158+
X beginning slash in getChild() threw an NPE
160159

161160
async requests
162161
Request r = createRequest("http://p5.org/feed/13134.jpg");

0 commit comments

Comments
 (0)