Check if html files contain non ASCII characters.
This commit is contained in:
@@ -473,6 +473,7 @@ public class Config
|
||||
public static boolean MULTIPLE_ITEM_DROP;
|
||||
public static boolean FORCE_INVENTORY_UPDATE;
|
||||
public static boolean LAZY_CACHE;
|
||||
public static boolean CHECK_HTML_ENCODING;
|
||||
public static boolean CACHE_CHAR_NAMES;
|
||||
public static int MIN_NPC_ANIMATION;
|
||||
public static int MAX_NPC_ANIMATION;
|
||||
@@ -2017,6 +2018,7 @@ public class Config
|
||||
MULTIPLE_ITEM_DROP = General.getBoolean("MultipleItemDrop", true);
|
||||
FORCE_INVENTORY_UPDATE = General.getBoolean("ForceInventoryUpdate", false);
|
||||
LAZY_CACHE = General.getBoolean("LazyCache", true);
|
||||
CHECK_HTML_ENCODING = General.getBoolean("CheckHtmlEncoding", true);
|
||||
CACHE_CHAR_NAMES = General.getBoolean("CacheCharNames", true);
|
||||
MIN_NPC_ANIMATION = General.getInt("MinNpcAnimation", 5);
|
||||
MAX_NPC_ANIMATION = General.getInt("MaxNpcAnimation", 60);
|
||||
@@ -3250,6 +3252,10 @@ public class Config
|
||||
|
||||
MULTILANG_DEFAULT = MultilingualSupport.getString("MultiLangDefault", "en").toLowerCase();
|
||||
MULTILANG_ENABLE = MultilingualSupport.getBoolean("MultiLangEnable", false);
|
||||
if (MULTILANG_ENABLE)
|
||||
{
|
||||
CHECK_HTML_ENCODING = false;
|
||||
}
|
||||
final String[] allowed = MultilingualSupport.getString("MultiLangAllowed", MULTILANG_DEFAULT).split(";");
|
||||
MULTILANG_ALLOWED = new ArrayList<>(allowed.length);
|
||||
for (String lang : allowed)
|
||||
|
@@ -115,6 +115,7 @@ public class HtmCache
|
||||
return null;
|
||||
}
|
||||
|
||||
String filePath = null;
|
||||
String content = null;
|
||||
try (FileInputStream fis = new FileInputStream(file);
|
||||
BufferedInputStream bis = new BufferedInputStream(fis))
|
||||
@@ -126,7 +127,13 @@ public class HtmCache
|
||||
content = new String(raw, StandardCharsets.UTF_8);
|
||||
content = content.replaceAll("(?s)<!--.*?-->", ""); // Remove html comments
|
||||
|
||||
final String oldContent = HTML_CACHE.put(file.toURI().getPath().substring(Config.DATAPACK_ROOT.toURI().getPath().length()), content);
|
||||
filePath = file.toURI().getPath().substring(Config.DATAPACK_ROOT.toURI().getPath().length());
|
||||
if (Config.CHECK_HTML_ENCODING && !filePath.startsWith("data/lang") && !StandardCharsets.US_ASCII.newEncoder().canEncode(content))
|
||||
{
|
||||
LOGGER.warning("HTML encoding check: File " + filePath + " contains non ASCII content.");
|
||||
}
|
||||
|
||||
final String oldContent = HTML_CACHE.put(filePath, content);
|
||||
if (oldContent == null)
|
||||
{
|
||||
_bytesBuffLen += bytes;
|
||||
|
Reference in New Issue
Block a user