Skip to content

Commit

Permalink
Fixes 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
autumoswitzerland committed Jul 8, 2024
1 parent fb8f55f commit 2186158
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 31 deletions.
Binary file modified db/h2/db/test/beetroot.mv.db
Binary file not shown.
49 changes: 18 additions & 31 deletions src/main/java/ch/autumo/beetroot/BeetRootWebServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -236,23 +235,15 @@ public void start(final int timeout) throws IOException {
* @throws IOException IO exception
*/
public void start(boolean daemon) throws IOException {

int timeout = - 1;

try {

timeout = BeetRootConfigurationManager.getInstance().getInt("connection_timeout");

if (timeout == -1) {

timeout = 5000;
LOG.error("Using 5 seconds for client connection timeout.");
}

timeout = timeout * 1000;

} catch (Exception e) {

timeout = 5000;
LOG.error("Couldn't read 'connection_timeout' from configuration. Using 5 seconds!");
}
Expand All @@ -268,9 +259,7 @@ public void start(boolean daemon) throws IOException {
*/
@Override
public void start(final int timeout, boolean daemon) throws IOException {

super.start(timeout, daemon);

try {
SessionManager.getInstance().load();
} catch (Exception e) {
Expand All @@ -283,15 +272,12 @@ public void start(final int timeout, boolean daemon) throws IOException {
*/
@Override
public void stop() {

super.stop();

try {
SessionManager.getInstance().save();
} catch (Exception e) {
LOG.warn("Couldn't save current user sessions!", e);
}

// Clear cache
FileCacheManager.getInstance().clear();
}
Expand Down Expand Up @@ -570,7 +556,8 @@ public Response serve(BeetRootHTTPSession session, HttpServletRequest request) {
// certainty of 99.99% (first files, max. cache isn't reached at all)
// So we can getTextData !
css = cache.getTextData();
css = css.replaceAll("url\\('", "url('/"+servletName); //test it: "url('" -> "url('/"+servletName
//css = css.replaceAll("url\\('", "url('/"+servletName);
css = css.replace("url('", "url('/"+servletName); //test it: "url('" -> "url('/"+servletName
parsedCss.put(filePath, css);
} else {
css = parsedCss.get(filePath);
Expand Down Expand Up @@ -1222,14 +1209,14 @@ public void addMappings() {
*/
private static class PwsParser {

public static Pattern PATTERN_INFO = Pattern.compile("\\{\\$pw.info\\}");
public static Pattern PATTERN_HIDE = Pattern.compile("\\{\\$pw.hide\\}");
public static Pattern PATTERN_SHOW = Pattern.compile("\\{\\$pw.show\\}");
public static Pattern PATTERN_CHARS = Pattern.compile("\\{\\$pw.chars\\}");
public static Pattern PATTERN_CAPITAL = Pattern.compile("\\{\\$pw.capital\\}");
public static Pattern PATTERN_NUMBER = Pattern.compile("\\{\\$pw.number\\}");
public static Pattern PATTERN_SPECIAL = Pattern.compile("\\{\\$pw.special\\}");
public static Pattern PATTERN_LETTER = Pattern.compile("\\{\\$pw.letter\\}");
public static final String PW_INFO = "{$pw.info}";
public static final String PW_HIDE = "{$pw.hide}";
public static final String PW_SHOW = "{$pw.show}";
public static final String PW_CHARS = "{$pw.chars}";
public static final String PW_CAPITAL = "{$pw.capital}";
public static final String PW_NUMBER = "{$pw.number}";
public static final String PW_SPECIAL = "{$pw.special}";
public static final String PW_LETTER = "{$pw.letter}";

/**
* Replace all variables.
Expand All @@ -1239,14 +1226,14 @@ private static class PwsParser {
* @return replaced java-script contents
*/
public static String parseAll(String script, Session userSession) {
script = PATTERN_INFO.matcher(script).replaceAll(LanguageManager.getInstance().translate("pw.info", userSession));
script = PATTERN_HIDE.matcher(script).replaceAll(LanguageManager.getInstance().translate("pw.hide", userSession));
script = PATTERN_SHOW.matcher(script).replaceAll(LanguageManager.getInstance().translate("pw.show", userSession));
script = PATTERN_CHARS.matcher(script).replaceAll(LanguageManager.getInstance().translate("pw.chars", userSession));
script = PATTERN_CAPITAL.matcher(script).replaceAll(LanguageManager.getInstance().translate("pw.capital", userSession));
script = PATTERN_NUMBER.matcher(script).replaceAll(LanguageManager.getInstance().translate("pw.number", userSession));
script = PATTERN_SPECIAL.matcher(script).replaceAll(LanguageManager.getInstance().translate("pw.special", userSession));
script = PATTERN_LETTER.matcher(script).replaceAll(LanguageManager.getInstance().translate("pw.letter", userSession));
script = script.replace(PW_INFO, LanguageManager.getInstance().translate("pw.info", userSession));
script = script.replace(PW_HIDE, LanguageManager.getInstance().translate("pw.hide", userSession));
script = script.replace(PW_SHOW, LanguageManager.getInstance().translate("pw.show", userSession));
script = script.replace(PW_CHARS, LanguageManager.getInstance().translate("pw.chars", userSession));
script = script.replace(PW_CAPITAL, LanguageManager.getInstance().translate("pw.capital", userSession));
script = script.replace(PW_NUMBER, LanguageManager.getInstance().translate("pw.number", userSession));
script = script.replace(PW_SPECIAL, LanguageManager.getInstance().translate("pw.special", userSession));
script = script.replace(PW_LETTER, LanguageManager.getInstance().translate("pw.letter", userSession));
return script;
}
}
Expand Down

0 comments on commit 2186158

Please sign in to comment.