Skip to content
Open

G #12

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
67 changes: 67 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

- name: Build with Gradle Wrapper
run: ./gradlew build

# NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html).
# If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version.
#
# - name: Setup Gradle
# uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
# with:
# gradle-version: '8.9'
#
# - name: Build with Gradle 8.9
# run: gradle build

dependency-submission:

runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
35 changes: 35 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
60 changes: 60 additions & 0 deletions .github/workflows/mdbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Sample workflow for building and deploying a mdBook site to GitHub Pages
#
# To get started with mdBook see: https://rust-lang.github.io/mdBook/index.html
#
name: Deploy mdBook site to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
env:
MDBOOK_VERSION: 0.4.36
steps:
- uses: actions/checkout@v4
- name: Install mdBook
run: |
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh
rustup update
cargo install --version ${MDBOOK_VERSION} mdbook
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Build with mdBook
run: mdbook build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./book

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ private static Stream<String> zidMapEntry() {
String zone001 = handlerMetaZones.zidMap().get(meta);
return zone001 == null ? "" :
String.format(" \"%s\", \"%s\", \"%s\",",
id, meta, zone001);
escape(id), escape(meta), escape(zone001));
})
.filter(s -> !s.isEmpty())
.sorted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public void startElement(String uri, String localName, String qName, Attributes
zones.put(attributes.getValue("other"), attributes.getValue("type"));
} else {
mzoneMapEntryList.add(String.format(" \"%s\", \"%s\", \"%s\",",
attributes.getValue("other"),
territory,
attributes.getValue("type")));
CLDRConverter.escape(attributes.getValue("other")),
CLDRConverter.escape(territory),
CLDRConverter.escape(attributes.getValue("type"))));
}
pushIgnoredContainer(qName);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ public void generateBundle(String packageName, String baseName, String localeID,
for (String key : map.keySet()) {
if (key.startsWith(CLDRConverter.METAZONE_ID_PREFIX)) {
String meta = key.substring(CLDRConverter.METAZONE_ID_PREFIX.length());
String[] value;
value = (String[]) map.get(key);
fmt.format(" final String[] %s = new String[] {\n", meta);
for (String s : value) {
fmt.format(" \"%s\",\n", CLDRConverter.escape(s));
if (map.get(key) instanceof String[] value) {
fmt.format(" final String[] %s = new String[] {\n", CLDRConverter.escape(meta));
for (String s : value) {
fmt.format(" \"%s\",\n", CLDRConverter.escape(s));
}
fmt.format(" };\n");
metaKeys.add(key);
}
fmt.format(" };\n");
metaKeys.add(key);
}
}
for (String key : metaKeys) {
Expand Down Expand Up @@ -143,15 +143,15 @@ public void generateBundle(String packageName, String baseName, String localeID,
if (fmt == null) {
fmt = new Formatter();
}
String metaVal = oldEntry.metaKey();
String metaVal = CLDRConverter.escape(oldEntry.metaKey());
if (val instanceof String[] values) {
fmt.format(" final String[] %s = new String[] {\n", metaVal);
for (String s : values) {
fmt.format(" \"%s\",\n", CLDRConverter.escape(s));
}
fmt.format(" };\n");
} else {
fmt.format(" final String %s = \"%s\";\n", metaVal, CLDRConverter.escape((String)val));
} else if (val instanceof String str) {
fmt.format(" final String %s = \"%s\";\n", metaVal, CLDRConverter.escape(str));
}
newMap.put(oldEntry.key, oldEntry.metaKey());
}
Expand All @@ -178,21 +178,21 @@ public void generateBundle(String packageName, String baseName, String localeID,
out.println(" final Object[][] data = new Object[][] {");
for (String key : map.keySet()) {
Object value = map.get(key);
var keyStr = CLDRConverter.escape(key);
if (value == null) {
CLDRConverter.warning("null value for " + key);
} else if (value instanceof String) {
String valStr = (String)value;
} else if (value instanceof String valStr) {
var escapedVal = CLDRConverter.escape(valStr);
if (type == BundleType.TIMEZONE &&
!(key.startsWith(CLDRConverter.EXEMPLAR_CITY_PREFIX) ||
key.startsWith(CLDRConverter.METAZONE_DSTOFFSET_PREFIX)) ||
valStr.startsWith(META_VALUE_PREFIX)) {
out.printf(" { \"%s\", %s },\n", key, CLDRConverter.escape(valStr));
out.printf(" { \"%s\", %s },\n", keyStr, escapedVal);
} else {
out.printf(" { \"%s\", \"%s\" },\n", key, CLDRConverter.escape(valStr));
out.printf(" { \"%s\", \"%s\" },\n", keyStr, escapedVal);
}
} else if (value instanceof String[]) {
String[] values = (String[]) value;
out.println(" { \"" + key + "\",\n new String[] {");
} else if (value instanceof String[] values) {
out.println(" { \"" + keyStr + "\",\n new String[] {");
for (String s : values) {
out.println(" \"" + CLDRConverter.escape(s) + "\",");
}
Expand Down Expand Up @@ -311,7 +311,7 @@ public class %s implements LocaleDataMetaInfo {
out.printf(" parentLocalesMap.put(Locale.ROOT,\n");
} else {
out.printf(" parentLocalesMap.put(Locale.forLanguageTag(\"%s\"),\n",
parentTag);
CLDRConverter.escape(parentTag));
}
generateStringArray(metaInfo.get(key), out);
}
Expand All @@ -320,7 +320,7 @@ public class %s implements LocaleDataMetaInfo {

// for languageAliasMap
CLDRConverter.handlerSupplMeta.getLanguageAliasData().forEach((key, value) -> {
out.printf(" languageAliasMap.put(\"%s\", \"%s\");\n", key, value);
out.printf(" languageAliasMap.put(\"%s\", \"%s\");\n", CLDRConverter.escape(key), CLDRConverter.escape(value));
});
out.printf(" }\n\n");

Expand All @@ -338,11 +338,11 @@ private static class CLDRMapHolder {
CLDRConverter.handlerTimeZone.getData().entrySet().stream()
.forEach(e -> {
String[] ids = ((String)e.getValue()).split("\\s");
out.printf(" tzCanonicalIDMap.put(\"%s\", \"%s\");\n", e.getKey(),
ids[0]);
out.printf(" tzCanonicalIDMap.put(\"%s\", \"%s\");\n", CLDRConverter.escape(e.getKey()),
CLDRConverter.escape(ids[0]));
for (int i = 1; i < ids.length; i++) {
out.printf(" tzCanonicalIDMap.put(\"%s\", \"%s\");\n", ids[i],
ids[0]);
out.printf(" tzCanonicalIDMap.put(\"%s\", \"%s\");\n", CLDRConverter.escape(ids[i]),
CLDRConverter.escape(ids[0]));
}
});
out.println();
Expand All @@ -352,8 +352,9 @@ private static class CLDRMapHolder {
if (key.startsWith(CLDRConverter.LIKELY_SCRIPT_PREFIX)) {
// ensure spaces at the begin/end for delimiting purposes
out.printf(" likelyScriptMap.put(\"%s\", \"%s\");\n",
key.substring(CLDRConverter.LIKELY_SCRIPT_PREFIX.length()),
" " + metaInfo.get(key).stream().collect(Collectors.joining(" ")) + " ");
CLDRConverter.escape(key.substring(CLDRConverter.LIKELY_SCRIPT_PREFIX.length())),
" " + metaInfo.get(key).stream()
.map(l -> CLDRConverter.escape(l)).collect(Collectors.joining(" ")) + " ");
}
}
out.printf(" }\n }\n");
Expand All @@ -371,7 +372,7 @@ public String availableLanguageTags(String category) {
return " %s";
}
""",
toLocaleList(applyLanguageAliases(metaInfo.get("AvailableLocales")), false));
CLDRConverter.escape(toLocaleList(applyLanguageAliases(metaInfo.get("AvailableLocales")), false)));

if(CLDRConverter.isBaseModule) {
out.printf("""
Expand Down Expand Up @@ -408,7 +409,7 @@ private static void generateStringArray(SortedSet<String> set, PrintWriter out)
int count = 0;
for (int i = 0; i < children.length; i++) {
String child = children[i];
out.printf("\"%s\", ", child);
out.printf("\"%s\", ", CLDRConverter.escape(child));
count += child.length() + 4;
if (i != children.length - 1 && count > 64) {
out.printf("\n ");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -85,7 +85,9 @@ public void startElement(String uri, String localName, String qName, Attributes

public Stream<String> deprecatedMap() {
return keySet().stream()
.map(k -> String.format(" \"%s\", \"%s\",", k, get(k)))
.map(k -> " \"%s\", \"%s\",".formatted(
CLDRConverter.escape(k),
CLDRConverter.escape((String)get(k))))
.sorted();
}
Map<String, String> getLanguageAliasData() {
Expand Down
Loading