Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,17 @@
if (language == null || language.isEmpty()) {
language = ANY_LANGUAGE;
}
List<Locale.LanguageRange> ranges = Locale.LanguageRange.parse(language);
List<Locale.LanguageRange> ranges;
try {
ranges = Locale.LanguageRange.parse(language);
} catch (IllegalArgumentException e) {
// The header is client-controlled: a malformed value must degrade to "no language
// preference", never turn every localized read on this request into a 500.
if (logger.isWarnEnabled()) {
logger.warn("Malformed Accept-Language header [{}] - ignoring it", language);
}
return "";
}
return ranges == null || ranges.isEmpty() ? ""
: ranges.get(0)
.getRange();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ List<String> listLanguages(String entityName) throws IOException {
for (CmisObject child : printFolder.get()
.getChildren()) {
if (child instanceof CmisFolder) {
languages.add(child.getName());
// The S3 CMS names a child folder with its trailing separator (en/) while the
// internal CMS does not - normalize so the language CODE contract is backend-neutral.
String code = child.getName();
while (code.endsWith(PATH_SEPARATOR)) {
code = code.substring(0, code.length() - 1);
}
if (!code.isEmpty()) {
languages.add(code);
}
}
}
return languages;
Expand Down
Loading