Skip to content

Commit

Permalink
Fix locale validator, don't sanitize already validated tz and locale …
Browse files Browse the repository at this point in the history
…and prepare for 6.1.3 rc2.
  • Loading branch information
snoopdave committed Feb 10, 2024
1 parent 0ed359f commit b8f11dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
8 changes: 4 additions & 4 deletions app/src/main/java/org/apache/roller/weblogger/pojos/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,25 +186,25 @@ public void setDateCreated(final Date date) {
}

/**
* Locale of the user.
* Locale of the user, must be valid Java locale.
*/
public String getLocale() {
return this.locale;
}

public void setLocale(String locale) {
this.locale = HTMLSanitizer.conditionallySanitize(locale);
this.locale = locale;
}

/**
* Timezone of the user.
* Timezone of the user, must be valid Java timezone.
*/
public String getTimeZone() {
return this.timeZone;
}

public void setTimeZone(String timeZone) {
this.timeZone = HTMLSanitizer.conditionallySanitize(timeZone);
this.timeZone = timeZone;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public void myValidate() {

// validate that bean's timeZone field is a valid time zone
if (!StringUtils.isEmpty(getBean().getTimeZone())) {
// looking up the time zone by id did not work for me
final Optional<String> first = Arrays.stream(TimeZone.getAvailableIDs())
.filter(id -> id.equals(getBean().getTimeZone())).findFirst();
if (first.isEmpty()) {
Expand All @@ -166,8 +167,10 @@ public void myValidate() {

// validate that bean's locale field is a valid locale
if (!StringUtils.isEmpty(getBean().getLocale())) {
Locale locale = Locale.forLanguageTag(bean.getLocale());
if (locale == null || "".equals(locale.getDisplayName())) {
// looking up the time zone by id did not work for me
final Optional<Locale> first = Arrays.stream(Locale.getAvailableLocales())
.filter(locale -> locale.toString().equals(getBean().getLocale())).findFirst();
if (first.isEmpty() || "".equals(first.get().getDisplayName())) {
addError("error.add.user.invalid.locale");
}
}
Expand Down
2 changes: 1 addition & 1 deletion assembly-release/sign-release.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

export rcstring="r1"
export rcstring="r2"
export vstring="6.1.3"

# for rc releases we rename the release files
Expand Down

0 comments on commit b8f11dd

Please sign in to comment.