Skip to content

Commit

Permalink
LPS-32234
Browse files Browse the repository at this point in the history
  • Loading branch information
petershin authored and brianchandotcom committed Jan 11, 2013
1 parent 2fee53c commit 6855ec6
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions portal-impl/src/com/liferay/portal/tools/SourceFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -739,16 +739,24 @@ private static String _fixSessionKey(
do {
String match = matcher.group();

int x = -1;
String str = null;

if (pattern.equals(_sessionKeyPattern)) {
x = match.indexOf(StringPool.COMMA);
str = StringPool.COMMA;
}
else if (pattern.equals(_taglibSessionKeyPattern)) {
x = match.indexOf("key=");
str = "key=";
}

String substring = match.substring(x + 1).trim();
int x = match.indexOf(str);

if (x == -1) {
continue;
}

x = x + str.length();

String substring = match.substring(x).trim();

String quote = StringPool.BLANK;

Expand All @@ -762,25 +770,31 @@ else if (substring.startsWith(StringPool.QUOTE)) {
continue;
}

int y = match.indexOf(quote, x + 1);
int y = match.indexOf(quote, x);
int z = match.indexOf(quote, y + 1);

if ((x == -1) || (y == -1) || (z == -1)) {
if ((y == -1) || (z == -1)) {
continue;
}

String prefix = match.substring(0, y + 1);
String suffix = match.substring(z);
String oldKey = match.substring(y + 1, z);

boolean alphaNumericKey = true;

for (char c : oldKey.toCharArray()) {
if (!Validator.isChar(c) || !Validator.isDigit(c) ||
(c != CharPool.DASH) || (c != CharPool.UNDERLINE)) {
if (!Validator.isChar(c) && !Validator.isDigit(c) &&
(c != CharPool.DASH) && (c != CharPool.UNDERLINE)) {

continue;
alphaNumericKey = false;
}
}

if (!alphaNumericKey) {
continue;
}

String newKey = TextFormatter.format(oldKey, TextFormatter.O);

newKey = TextFormatter.format(newKey, TextFormatter.M);
Expand Down

0 comments on commit 6855ec6

Please sign in to comment.