mirror of
				https://github.com/PlaceholderAPI/PlaceholderAPI
				synced 2025-10-31 06:12:28 +01:00 
			
		
		
		
	updated char replacer to better handle malformed input
This commit is contained in:
		| @@ -54,20 +54,19 @@ public final class CharsReplacer implements Replacer | |||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			boolean identified = false; | 			boolean identified = false; | ||||||
| 			boolean oopsitsbad = false; | 			boolean oopsitsbad = true; | ||||||
|  |  | ||||||
| 			while (++i < chars.length) | 			while (++i < chars.length) | ||||||
| 			{ | 			{ | ||||||
| 				final char p = chars[i]; | 				final char p = chars[i]; | ||||||
|  |  | ||||||
| 				if (p == closure.tail) | 				if (p == ' ') | ||||||
| 				{ | 				{ | ||||||
| 					break; | 					break; | ||||||
| 				} | 				} | ||||||
|  | 				if (p == closure.tail) | ||||||
| 				if (p == ' ') |  | ||||||
| 				{ | 				{ | ||||||
| 					oopsitsbad = true; | 					oopsitsbad = false; | ||||||
| 					break; | 					break; | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| @@ -109,14 +108,28 @@ public final class CharsReplacer implements Replacer | |||||||
| 			final PlaceholderHook placeholder = lookup.apply(identifierString); | 			final PlaceholderHook placeholder = lookup.apply(identifierString); | ||||||
| 			if (placeholder == null) | 			if (placeholder == null) | ||||||
| 			{ | 			{ | ||||||
| 				builder.append(closure.head).append(identifierString).append('_').append(parametersString).append(closure.tail); | 				builder.append(closure.head).append(identifierString); | ||||||
|  |  | ||||||
|  | 				if (identified) | ||||||
|  | 				{ | ||||||
|  | 					builder.append('_'); | ||||||
|  | 				} | ||||||
|  |  | ||||||
|  | 				builder.append(parametersString).append(closure.tail); | ||||||
| 				continue; | 				continue; | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			final String replacement = placeholder.onRequest(player, parametersString); | 			final String replacement = placeholder.onRequest(player, parametersString); | ||||||
| 			if (replacement == null) | 			if (replacement == null) | ||||||
| 			{ | 			{ | ||||||
| 				builder.append(closure.head).append(identifierString).append('_').append(parametersString).append(closure.tail); | 				builder.append(closure.head).append(identifierString); | ||||||
|  |  | ||||||
|  | 				if (identified) | ||||||
|  | 				{ | ||||||
|  | 					builder.append('_'); | ||||||
|  | 				} | ||||||
|  |  | ||||||
|  | 				builder.append(parametersString).append(closure.tail); | ||||||
| 				continue; | 				continue; | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user