Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

enforce UTF-8 encoding during file output #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions src/main/java/net/vaemendis/hccd/CardGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class CardGenerator {

private static final String GENERATED_SUFFIX = "-GENERATED";

private static final String ENCODING = "UTF-8";

public static void generateCards(WatchedFiles projectFiles, UserConfiguration config) throws IOException {
Hccd.log("Generating card sheet file...");
if (!projectFiles.getCsvFile().isFile()) {
Expand Down Expand Up @@ -77,7 +79,7 @@ public static void generateCards(WatchedFiles projectFiles, UserConfiguration co
}
writeFooter(sb);

FileUtils.writeStringToFile(target, sb.toString());
FileUtils.writeStringToFile(target, sb.toString(), ENCODING);
Hccd.log("Card sheet file written to " + target.getPath());
}
}
Expand All @@ -86,7 +88,7 @@ private static void writeHeader(StringBuilder sb, String cssFilePath) {
sb.append("<!doctype html>" +
"<html>" +
"<head>" +
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></meta>" +
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset="+ENCODING+"\"></meta>" +
"<meta http-equiv=\"Content-Security-Policy\" content=\"script-src 'unsafe-inline';\">" +
"<meta http-equiv=\"X-Content-Security-Policy\" content=\"script-src 'unsafe-inline';\">" +
"<meta http-equiv=\"X-WebKit-CSP\" content=\"script-src 'unsafe-inline';\">" +
Expand Down