@@ -148,7 +148,55 @@ sap.ui.define(["sap/ui/core/BusyIndicator", "sap/m/MessageBox"
148148 }
149149 } ,
150150 responseError ( response ) {
151- document . write ( response ) ;
151+ // Security: Display HTML response in iframe for safe rendering
152+ BusyIndicator . hide ( ) ;
153+
154+ // Limit response length to prevent UI issues
155+ const maxLength = 50000 ; // Increased for HTML content
156+ let errorMessage = String ( response ) ;
157+ if ( errorMessage . length > maxLength ) {
158+ errorMessage =
159+ errorMessage . substring ( 0 , maxLength ) +
160+ "\n\n<!-- Content truncated - too long -->" ;
161+ }
162+
163+ // Create or get existing error container
164+ let errorContainer = document . getElementById ( "serverErrorContainer" ) ;
165+ if ( ! errorContainer ) {
166+ errorContainer = document . createElement ( "div" ) ;
167+ errorContainer . id = "serverErrorContainer" ;
168+ errorContainer . style . cssText = `
169+ position: fixed;
170+ top: 50%;
171+ left: 50%;
172+ transform: translate(-50%, -50%);
173+ width: 90%;
174+ height: 90%;
175+ background: white;
176+ border: 2px solid #d32f2f;
177+ border-radius: 4px;
178+ box-shadow: 0 4px 6px rgba(0,0,0,0.3);
179+ z-index: 9999;
180+ display: flex;
181+ flex-direction: column;
182+ ` ;
183+ document . body . appendChild ( errorContainer ) ;
184+ }
185+
186+ // Create header and iframe for safe HTML rendering
187+ errorContainer . innerHTML = `
188+ <div style="padding: 15px; background: #d32f2f; color: white; display: flex; justify-content: space-between; align-items: center;">
189+ <h3 style="margin: 0;">Server Error - Please Restart The App</h3>
190+ </div>
191+ <iframe id="errorIframe" style="width: 100%; height: 100%; border: none; flex: 1;" sandbox="allow-same-origin"></iframe>
192+ ` ;
193+
194+ // Render HTML in iframe (sandbox for security)
195+ const iframe = document . getElementById ( "errorIframe" ) ;
196+ iframe . contentDocument . open ( ) ;
197+ iframe . contentDocument . write ( errorMessage ) ;
198+ iframe . contentDocument . close ( ) ;
199+
152200 } ,
153201 } ;
154202 } ) ;
0 commit comments