Merge "make preferences check for [ and ] in key"

This commit is contained in:
Thomas Clark (WPI)
2014-10-19 14:57:42 -07:00
committed by Gerrit Code Review
2 changed files with 21 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2011. All Rights Reserved. */
/* Copyright (c) FIRST 2011. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
@@ -564,18 +564,20 @@ void Preferences::WriteTaskRun()
}
static bool isKeyAcceptable(const std::string& value) {
for (unsigned int i = 0; i < value.length(); i++) {
char letter = value.at(i);
switch (letter) {
case '=':
case '\n':
case '\r':
case ' ':
case '\t':
return false;
}
}
return true;
for (unsigned int i = 0; i < value.length(); i++) {
char letter = value.at(i);
switch (letter) {
case '=':
case '\n':
case '\r':
case ' ':
case '\t':
case '[':
case ']':
return false;
}
}
return true;
}
void Preferences::ValueChanged(ITable* table, const std::string& key, EntryValue value, bool isNew)
{

View File

@@ -503,7 +503,7 @@ public class Preferences {
file.createNewFile();
output = new FileOutputStream(file);
output.write("[Preferences]\n".getBytes());
for (int i = 0; i < keys.size(); i++) {
@@ -803,6 +803,8 @@ public class Preferences {
case '\r':
case ' ':
case '\t':
case '[':
case ']':
throw new ImproperPreferenceKeyException(value, letter);
}
}
@@ -813,7 +815,7 @@ public class Preferences {
* preference table.
*
* @param value
* @return
* @return true if the given string is ok to use in the preference table
*/
public static boolean isAcceptable(String value) {
for (int i = 0; i < value.length(); i++) {
@@ -824,6 +826,8 @@ public class Preferences {
case '\r':
case ' ':
case '\t':
case '[':
case ']':
return false;
}
}