From 96f6f081e2e7deb75a7075cdd9c324fbc796b67e Mon Sep 17 00:00:00 2001 From: Hongchol Sinn Date: Tue, 29 Aug 2023 14:38:57 -0700 Subject: [PATCH] fix: UAA login page breaks when the product logo images is over 100000 characters - UAA log contained the following message: ``` Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1078E: Concatenated string is too long, exceeding the threshold of '100,000' characters ``` - Moved the concatenation code from html templates, that are subject to Spring Expression Language, to Java code. [#185950696] [original story: #185894942] Co-authored-by: Peter Chen Co-authored-by: Danny Faught Co-authored-by: Alicia Yingling Co-authored-by: Bruce Ricard --- .../identity/uaa/zone/MergedZoneBrandingInformation.java | 8 ++++++++ .../src/main/resources/templates/web/layouts/main.html | 4 ++-- .../web/layouts/pui-account-discovery-main.html | 2 +- .../resources/templates/web/layouts/pui-mfa-main.html | 2 +- .../identity/uaa/login/LoginMockMvcTests.java | 9 +++++++++ 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/cloudfoundry/identity/uaa/zone/MergedZoneBrandingInformation.java b/server/src/main/java/org/cloudfoundry/identity/uaa/zone/MergedZoneBrandingInformation.java index f059575d619..022bc1f5a32 100644 --- a/server/src/main/java/org/cloudfoundry/identity/uaa/zone/MergedZoneBrandingInformation.java +++ b/server/src/main/java/org/cloudfoundry/identity/uaa/zone/MergedZoneBrandingInformation.java @@ -33,6 +33,14 @@ public String getProductLogo() { return tryGet(IdentityZoneHolder.get(), BrandingInformationSource::getProductLogo).orElse(null); } + public String getInlinedBase64PngLogo() { + String logo = getProductLogo(); + if ( logo != null ) { + logo = "data:image/png;base64," + logo; + } + return logo; + } + @Override public String getSquareLogo() { return resolve(BrandingInformationSource::getSquareLogo); diff --git a/server/src/main/resources/templates/web/layouts/main.html b/server/src/main/resources/templates/web/layouts/main.html index 9d6fcad646a..9e00f2f6bc7 100644 --- a/server/src/main/resources/templates/web/layouts/main.html +++ b/server/src/main/resources/templates/web/layouts/main.html @@ -8,9 +8,9 @@ copyrightCompanyName=${branding.getCompanyName() ?: 'CloudFoundry.org Foundation, Inc. '}, copyrightFallback=${'Copyright © ' + copyrightCompanyName + ' ' + #dates.year(#dates.createNow()) + '. All Rights Reserved.'}, copyright=${branding.getFooterLegalText() ?: copyrightFallback}, - brandingLogo=${branding.getProductLogo()}, + brandingLogo=${branding.getInlinedBase64PngLogo()}, fallbackLogo=${isUaa ? assetBaseUrl+'/images/product-logo.png' : null}, - logo=${brandingLogo != null ? 'data:image/png;base64,'+#strings.replace(brandingLogo,T(java.lang.System).getProperty('line.separator'),'') : fallbackLogo}" > + logo=${brandingLogo != null ? #strings.replace(brandingLogo,T(java.lang.System).getProperty('line.separator'),'') : fallbackLogo}" > diff --git a/server/src/main/resources/templates/web/layouts/pui-account-discovery-main.html b/server/src/main/resources/templates/web/layouts/pui-account-discovery-main.html index 20defaa8ed1..f8ee9a23c74 100644 --- a/server/src/main/resources/templates/web/layouts/pui-account-discovery-main.html +++ b/server/src/main/resources/templates/web/layouts/pui-account-discovery-main.html @@ -42,7 +42,7 @@