summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp')
-rw-r--r--Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp b/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp
index 16a540c91..92ce4685a 100644
--- a/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp
+++ b/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp
@@ -31,6 +31,8 @@
#include "FileSystem.h"
#include <hyphen.h>
+#include <limits>
+#include <stdlib.h>
#include <wtf/HashMap.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/TinyLRUCache.h>
@@ -62,8 +64,14 @@ static String extractLocaleFromDictionaryFilePath(const String& filePath)
static void scanDirectoryForDicionaries(const char* directoryPath, HashMap<AtomicString, Vector<String>>& availableLocales)
{
- for (const auto& filePath : listDirectory(directoryPath, "hyph_*.dic")) {
+ for (auto& filePath : listDirectory(directoryPath, "hyph_*.dic")) {
String locale = extractLocaleFromDictionaryFilePath(filePath).convertToASCIILowercase();
+
+ char normalizedPath[PATH_MAX];
+ if (!realpath(fileSystemRepresentation(filePath).data(), normalizedPath))
+ continue;
+
+ filePath = stringFromFileSystemRepresentation(normalizedPath);
availableLocales.add(locale, Vector<String>()).iterator->value.append(filePath);
String localeReplacingUnderscores = String(locale);
@@ -170,9 +178,9 @@ template<>
class TinyLRUCachePolicy<AtomicString, RefPtr<HyphenationDictionary>>
{
public:
- static TinyLRUCache<AtomicString, RefPtr<HyphenationDictionary>>& cache()
+ static TinyLRUCache<AtomicString, RefPtr<WebCore::HyphenationDictionary>, 32>& cache()
{
- static NeverDestroyed<TinyLRUCache<AtomicString, RefPtr<HyphenationDictionary>>> cache;
+ static NeverDestroyed<TinyLRUCache<AtomicString, RefPtr<WebCore::HyphenationDictionary>, 32>> cache;
return cache;
}