Initial commit: update

This commit is contained in:
chris
2026-10-20 20:22:38 +00:00
parent b6a6c5de5c
commit 1814ea3a0f
225 changed files with 15006 additions and 1 deletions

View File

@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="de"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>HmiStyles.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">backend</a> &gt; <a href="index.source.html" class="el_package">com.workbenchclassic.hmi</a> &gt; <span class="el_source">HmiStyles.java</span></div><h1>HmiStyles.java</h1><pre class="source lang-java linenums">package com.workbenchclassic.hmi;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletContext;
/** Shared CSS source for admin API and public, read-only stylesheet servlet. */
final class HmiStyles {
private HmiStyles() { }
static String original(ServletContext context) throws IOException {
<span class="nc" id="L18"> try (InputStream stream = context.getResourceAsStream(&quot;/ios.css&quot;)) {</span>
<span class="nc bnc" id="L19" title="All 2 branches missed."> if (stream == null) throw new IOException(&quot;Original ios.css missing in deployed WAR&quot;);</span>
<span class="nc" id="L20"> try (Reader r = new InputStreamReader(stream, StandardCharsets.UTF_8)) { return read(r); }</span>
}
}
static String read(Reader r) throws IOException {
<span class="nc" id="L24"> char[] buf = new char[8192]; int n; StringBuilder value = new StringBuilder();</span>
<span class="nc bnc" id="L25" title="All 2 branches missed."> while ((n=r.read(buf))&gt;=0) {</span>
<span class="nc" id="L26"> value.append(buf,0,n);</span>
<span class="nc bnc" id="L27" title="All 2 branches missed."> if (value.length()&gt;512*1024) throw new IOException(&quot;CSS exceeds 512 KiB&quot;);</span>
}
<span class="nc" id="L29"> return value.toString();</span>
}
static String published() throws SQLException, IOException {
<span class="nc" id="L32"> try (Connection c=HmiDb.open();PreparedStatement p=c.prepareStatement(</span>
<span class="nc" id="L33"> &quot;SELECT CSS_CONTENT FROM &quot;+HmiDb.schemaPrefix()+&quot;HMI_APP_CSS_REVISION WHERE STATUS = ? ORDER BY VERSION_NO DESC&quot;)) {</span>
<span class="nc" id="L34"> p.setString(1,&quot;PUBLISHED&quot;);try(ResultSet rs=p.executeQuery()){</span>
<span class="nc bnc" id="L35" title="All 2 branches missed."> if(rs.next()) try (Reader r=rs.getCharacterStream(1)){return read(r);}</span>
<span class="nc bnc" id="L36" title="All 2 branches missed."> }</span>
<span class="nc bnc" id="L37" title="All 4 branches missed."> }</span>
<span class="nc" id="L38"> return null;</span>
}
/** CSS is powerful. Disallow external fetches, embedded HTML and CSS behaviors. Restrict authoring to approved roles. */
static void validate(String css) {
<span class="nc bnc" id="L42" title="All 6 branches missed."> if (css==null || css.isEmpty() || css.length()&gt;512*1024) throw new IllegalArgumentException(&quot;CSS muss zwischen 1 und 524288 Zeichen umfassen&quot;);</span>
// Reject remote resources, CSS escapes, and HTML/script injection in published styles.
<span class="nc bnc" id="L44" title="All 2 branches missed."> if (css.indexOf('\\')&gt;=0 || java.util.regex.Pattern.compile(</span>
<span class="nc bnc" id="L45" title="All 2 branches missed."> &quot;(?i)@import\\b|url\\s*\\(|image-set\\s*\\(|@font-face\\b|@namespace\\b|expression\\s*\\(|behavior\\s*:|-moz-binding\\s*:|https?://|data:|&lt;|&gt;&quot;).matcher(css).find())</span>
<span class="nc" id="L46"> throw new IllegalArgumentException(&quot;CSS enthält externe Ressourcen oder nicht erlaubte Inhalte&quot;);</span>
<span class="nc bnc" id="L47" title="All 4 branches missed."> if (!css.contains(&quot;{&quot;) || !css.contains(&quot;}&quot;)) throw new IllegalArgumentException(&quot;CSS-Regeln fehlen&quot;);</span>
<span class="nc" id="L48"> }</span>
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.4.201905082037</span></div></body></html>