|
|
@ -378,7 +378,6 @@ make_config! {
|
|
|
|
|
|
|
|
|
|
|
|
fn validate_config(cfg: &ConfigItems) -> Result<(), Error> {
|
|
|
|
fn validate_config(cfg: &ConfigItems) -> Result<(), Error> {
|
|
|
|
let db_url = cfg.database_url.to_lowercase();
|
|
|
|
let db_url = cfg.database_url.to_lowercase();
|
|
|
|
|
|
|
|
|
|
|
|
if cfg!(feature = "sqlite") && (db_url.starts_with("mysql:") || db_url.starts_with("postgresql:")) {
|
|
|
|
if cfg!(feature = "sqlite") && (db_url.starts_with("mysql:") || db_url.starts_with("postgresql:")) {
|
|
|
|
err!("`DATABASE_URL` is meant for MySQL or Postgres, while this server is meant for SQLite")
|
|
|
|
err!("`DATABASE_URL` is meant for MySQL or Postgres, while this server is meant for SQLite")
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -447,12 +446,7 @@ impl Config {
|
|
|
|
validate_config(&config)?;
|
|
|
|
validate_config(&config)?;
|
|
|
|
|
|
|
|
|
|
|
|
Ok(Config {
|
|
|
|
Ok(Config {
|
|
|
|
inner: RwLock::new(Inner {
|
|
|
|
inner: RwLock::new(Inner { templates: load_templates(&config.templates_folder), config, _env, _usr }),
|
|
|
|
templates: load_templates(&config.templates_folder),
|
|
|
|
|
|
|
|
config,
|
|
|
|
|
|
|
|
_env,
|
|
|
|
|
|
|
|
_usr,
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -500,9 +494,8 @@ impl Config {
|
|
|
|
let e: Vec<&str> = email.rsplitn(2, '@').collect();
|
|
|
|
let e: Vec<&str> = email.rsplitn(2, '@').collect();
|
|
|
|
if e.len() != 2 || e[0].is_empty() || e[1].is_empty() {
|
|
|
|
if e.len() != 2 || e[0].is_empty() || e[1].is_empty() {
|
|
|
|
warn!("Failed to parse email address '{}'", email);
|
|
|
|
warn!("Failed to parse email address '{}'", email);
|
|
|
|
return false
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
self.signups_domains_whitelist().split(',').any(|d| d == e[0])
|
|
|
|
self.signups_domains_whitelist().split(',').any(|d| d == e[0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -634,9 +627,7 @@ impl HelperDef for CaseHelper {
|
|
|
|
rc: &mut RenderContext<'reg>,
|
|
|
|
rc: &mut RenderContext<'reg>,
|
|
|
|
out: &mut dyn Output,
|
|
|
|
out: &mut dyn Output,
|
|
|
|
) -> HelperResult {
|
|
|
|
) -> HelperResult {
|
|
|
|
let param = h
|
|
|
|
let param = h.param(0).ok_or_else(|| RenderError::new("Param not found for helper \"case\""))?;
|
|
|
|
.param(0)
|
|
|
|
|
|
|
|
.ok_or_else(|| RenderError::new("Param not found for helper \"case\""))?;
|
|
|
|
|
|
|
|
let value = param.value().clone();
|
|
|
|
let value = param.value().clone();
|
|
|
|
|
|
|
|
|
|
|
|
if h.params().iter().skip(1).any(|x| x.value() == &value) {
|
|
|
|
if h.params().iter().skip(1).any(|x| x.value() == &value) {
|
|
|
@ -658,14 +649,10 @@ impl HelperDef for JsEscapeHelper {
|
|
|
|
_: &mut RenderContext<'reg>,
|
|
|
|
_: &mut RenderContext<'reg>,
|
|
|
|
out: &mut dyn Output,
|
|
|
|
out: &mut dyn Output,
|
|
|
|
) -> HelperResult {
|
|
|
|
) -> HelperResult {
|
|
|
|
let param = h
|
|
|
|
let param = h.param(0).ok_or_else(|| RenderError::new("Param not found for helper \"js_escape\""))?;
|
|
|
|
.param(0)
|
|
|
|
|
|
|
|
.ok_or_else(|| RenderError::new("Param not found for helper \"js_escape\""))?;
|
|
|
|
let value =
|
|
|
|
|
|
|
|
param.value().as_str().ok_or_else(|| RenderError::new("Param for helper \"js_escape\" is not a String"))?;
|
|
|
|
let value = param
|
|
|
|
|
|
|
|
.value()
|
|
|
|
|
|
|
|
.as_str()
|
|
|
|
|
|
|
|
.ok_or_else(|| RenderError::new("Param for helper \"js_escape\" is not a String"))?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let escaped_value = value.replace('\\', "").replace('\'', "\\x22").replace('\"', "\\x27");
|
|
|
|
let escaped_value = value.replace('\\', "").replace('\'', "\\x22").replace('\"', "\\x27");
|
|
|
|
let quoted_value = format!(""{}"", escaped_value);
|
|
|
|
let quoted_value = format!(""{}"", escaped_value);
|
|
|
|