|
@@ -53,6 +53,22 @@ public class ActionSubstitutor {
|
53
|
53
|
private static final String ERR_NOT_DEFINED = "not_defined";
|
54
|
54
|
/** Substitution to use to replace subs with illegal components. */
|
55
|
55
|
private static final String ERR_ILLEGAL_COMPONENT = "illegal_component";
|
|
56
|
+
|
|
57
|
+ /** Pattern used to match braced substitutions. */
|
|
58
|
+ private static final Pattern BRACES_PATTERN = Pattern.compile("(?<!\\\\)((?:\\\\\\\\)*)"
|
|
59
|
+ + "(\\$\\{([^{}]*?)\\})");
|
|
60
|
+ /** Pattern used to match all other substitutions. */
|
|
61
|
+ private static final Pattern OTHER_PATTERN = Pattern.compile("(?<!\\\\)((?:\\\\\\\\)*)(\\$("
|
|
62
|
+ + "[0-9]+(-([0-9]+)?)?|" // Word subs - $1, $1-, $1-2
|
|
63
|
+ + "[0-9]+(\\.([A-Z_]+))+|" // Component subs - 2.FOO_BAR
|
|
64
|
+ + "[a-z0-9A-Z_\\.]+" // Config/server subs
|
|
65
|
+ + "))");
|
|
66
|
+ /** Pattern to determine if a substitution is a word number type. */
|
|
67
|
+ private final static Pattern NUMBER_PATTERN = Pattern.compile("([0-9]+)(-([0-9]+)?)?");
|
|
68
|
+ /** Pattern to determine if a substitution is an argument+component type. */
|
|
69
|
+ private final static Pattern COMP_PATTERN = Pattern.compile("([0-9]+)\\.([A-Z_]+(\\.[A-Z_]+)*)");
|
|
70
|
+ /** Pattern to determine if a substitution is a server component type. */
|
|
71
|
+ private final static Pattern SERVER_PATTERN = Pattern.compile("[A-Z_]+(\\.[A-Z_]+)*");
|
56
|
72
|
|
57
|
73
|
/** The action type this substitutor is for. */
|
58
|
74
|
private final ActionType type;
|
|
@@ -174,16 +190,8 @@ public class ActionSubstitutor {
|
174
|
190
|
|
175
|
191
|
final StringBuilder res = new StringBuilder(target);
|
176
|
192
|
|
177
|
|
- final Pattern bracesPattern = Pattern.compile("(?<!\\\\)((?:\\\\\\\\)*)"
|
178
|
|
- + "(\\$\\{([^{}]*?)\\})");
|
179
|
|
- final Pattern otherPattern = Pattern.compile("(?<!\\\\)((?:\\\\\\\\)*)(\\$("
|
180
|
|
- + "[0-9]+(-([0-9]+)?)?|" // Word subs - $1, $1-, $1-2
|
181
|
|
- + "[0-9]+(\\.([A-Z_]+))+|" // Component subs - 2.FOO_BAR
|
182
|
|
- + "[a-z0-9A-Z_\\.]+" // Config/server subs
|
183
|
|
- + "))");
|
184
|
|
-
|
185
|
|
- Matcher bracesMatcher = bracesPattern.matcher(res);
|
186
|
|
- Matcher otherMatcher = otherPattern.matcher(res);
|
|
193
|
+ Matcher bracesMatcher = BRACES_PATTERN.matcher(res);
|
|
194
|
+ Matcher otherMatcher = OTHER_PATTERN.matcher(res);
|
187
|
195
|
|
188
|
196
|
boolean first;
|
189
|
197
|
|
|
@@ -196,8 +204,8 @@ public class ActionSubstitutor {
|
196
|
204
|
res.delete(start, end);
|
197
|
205
|
res.insert(start, getSubstitution(doSubstitution(group, args), args));
|
198
|
206
|
|
199
|
|
- bracesMatcher = bracesPattern.matcher(res);
|
200
|
|
- otherMatcher = otherPattern.matcher(res);
|
|
207
|
+ bracesMatcher = BRACES_PATTERN.matcher(res);
|
|
208
|
+ otherMatcher = OTHER_PATTERN.matcher(res);
|
201
|
209
|
}
|
202
|
210
|
|
203
|
211
|
return res.toString().replaceAll("\\\\(.)", "$1");
|
|
@@ -211,11 +219,9 @@ public class ActionSubstitutor {
|
211
|
219
|
* @return The substitution to be used
|
212
|
220
|
*/
|
213
|
221
|
private String getSubstitution(final String substitution, final Object ... args) {
|
214
|
|
- final Pattern numberPattern = Pattern.compile("([0-9]+)(-([0-9]+)?)?");
|
215
|
|
- final Matcher numberMatcher = numberPattern.matcher(substitution);
|
216
|
|
-
|
217
|
|
- final Pattern compPattern = Pattern.compile("([0-9]+)\\.([A-Z_]+(\\.[A-Z_]+)*)");
|
218
|
|
- final Matcher compMatcher = compPattern.matcher(substitution);
|
|
222
|
+ final Matcher numberMatcher = NUMBER_PATTERN.matcher(substitution);
|
|
223
|
+ final Matcher compMatcher = COMP_PATTERN.matcher(substitution);
|
|
224
|
+ final Matcher serverMatcher = SERVER_PATTERN.matcher(substitution);
|
219
|
225
|
|
220
|
226
|
if (usesWordSubstitutions() && numberMatcher.matches()) {
|
221
|
227
|
final CommandArguments words = args[2] instanceof String ?
|
|
@@ -253,7 +259,7 @@ public class ActionSubstitutor {
|
253
|
259
|
return manager.getOption("actions", substitution);
|
254
|
260
|
}
|
255
|
261
|
|
256
|
|
- if (hasFrameContainer()) {
|
|
262
|
+ if (hasFrameContainer() && serverMatcher.matches()) {
|
257
|
263
|
final Server server = ((FrameContainer) args[0]).getServer();
|
258
|
264
|
|
259
|
265
|
if (server != null) {
|