mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 14:30:56 +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 OPTIONAL_PREFIX = "?";
|
||||||
private static final String WILDCARD_PREFIX = "*.";
|
private static final String WILDCARD_PREFIX = "*.";
|
||||||
|
|
||||||
|
private static int parseColorDepth;
|
||||||
|
|
||||||
static void loadDefaultsFromProperties( Class<?> lookAndFeelClass, List<FlatDefaultsAddon> addons,
|
static void loadDefaultsFromProperties( Class<?> lookAndFeelClass, List<FlatDefaultsAddon> addons,
|
||||||
Properties additionalDefaults, boolean dark, UIDefaults defaults )
|
Properties additionalDefaults, boolean dark, UIDefaults defaults )
|
||||||
{
|
{
|
||||||
@@ -580,6 +582,11 @@ class UIDefaultsLoader
|
|||||||
if( params.isEmpty() )
|
if( params.isEmpty() )
|
||||||
throw new IllegalArgumentException( "missing parameters in function '" + value + "'" );
|
throw new IllegalArgumentException( "missing parameters in function '" + value + "'" );
|
||||||
|
|
||||||
|
if( parseColorDepth > 100 )
|
||||||
|
throw new IllegalArgumentException( "endless recursion in color function '" + value + "'" );
|
||||||
|
|
||||||
|
parseColorDepth++;
|
||||||
|
try {
|
||||||
switch( function ) {
|
switch( function ) {
|
||||||
case "rgb": return parseColorRgbOrRgba( false, params, resolver, reportError );
|
case "rgb": return parseColorRgbOrRgba( false, params, resolver, reportError );
|
||||||
case "rgba": return parseColorRgbOrRgba( true, 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 "fade": return parseColorFade( params, resolver, reportError );
|
||||||
case "spin": return parseColorSpin( params, resolver, reportError );
|
case "spin": return parseColorSpin( params, resolver, reportError );
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
parseColorDepth--;
|
||||||
|
}
|
||||||
|
|
||||||
throw new IllegalArgumentException( "unknown color function '" + value + "'" );
|
throw new IllegalArgumentException( "unknown color function '" + value + "'" );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user