mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 06:20:53 +03:00
UIDefaultsLoader: check for endless recursion in parsing color functions (e.g. abc = darken($abc,10%))
This commit is contained in:
@@ -72,6 +72,8 @@ class UIDefaultsLoader
|
||||
private static final String OPTIONAL_PREFIX = "?";
|
||||
private static final String WILDCARD_PREFIX = "*.";
|
||||
|
||||
private static int parseColorDepth;
|
||||
|
||||
static void loadDefaultsFromProperties( Class<?> lookAndFeelClass, List<FlatDefaultsAddon> addons,
|
||||
Properties additionalDefaults, boolean dark, UIDefaults defaults )
|
||||
{
|
||||
@@ -580,6 +582,11 @@ class UIDefaultsLoader
|
||||
if( params.isEmpty() )
|
||||
throw new IllegalArgumentException( "missing parameters in function '" + value + "'" );
|
||||
|
||||
if( parseColorDepth > 100 )
|
||||
throw new IllegalArgumentException( "endless recursion in color function '" + value + "'" );
|
||||
|
||||
parseColorDepth++;
|
||||
try {
|
||||
switch( function ) {
|
||||
case "rgb": return parseColorRgbOrRgba( false, params, resolver, reportError );
|
||||
case "rgba": return parseColorRgbOrRgba( true, params, resolver, reportError );
|
||||
@@ -594,6 +601,9 @@ class UIDefaultsLoader
|
||||
case "fade": return parseColorFade( params, resolver, reportError );
|
||||
case "spin": return parseColorSpin( params, resolver, reportError );
|
||||
}
|
||||
} finally {
|
||||
parseColorDepth--;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException( "unknown color function '" + value + "'" );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user