[Fontconfig] fontconfig: Branch 'master'
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Oct 10 07:54:34 UTC 2019
src/fcxml.c | 5 +++
test/Makefile.am | 16 ++++++++++-
test/run-test.sh | 22 +++++++--------
test/test-issue180.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 104 insertions(+), 12 deletions(-)
New commits:
commit 75eadca26648abf69497691ff0f4c7803b9ff23c
Author: Akira TAGOH <akira at tagoh.org>
Date: Tue Oct 8 19:35:10 2019 +0900
Warn as well if no directory name for cachedir provided
cachedir is used to determine where cache files are stored.
the empty directory will ends up to put them under the top of
directory of XDG_CACHE_HOME. that messes it up and must be avoided.
As a note, if you want to read/write something from the top of
XDG_DATA_HOME (dir) and/or XDG_CACHE_HOME (cachedir),
put "." instead of the empty.
https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/180
diff --git a/src/fcxml.c b/src/fcxml.c
index 076fa30..d9a67f6 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -2301,6 +2301,11 @@ FcParseCacheDir (FcConfigParse *parse)
data = prefix;
goto bail;
}
+ if (data[0] == 0)
+ {
+ FcConfigMessage (parse, FcSevereWarning, "empty cache directory name ignored");
+ return;
+ }
if (prefix)
{
size_t plen = strlen ((const char *)prefix);
diff --git a/test/Makefile.am b/test/Makefile.am
index a9fa089..e44aa0b 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -135,8 +135,22 @@ check_PROGRAMS += test-bz1744377
test_bz1744377_LDADD = $(top_builddir)/src/libfontconfig.la
TESTS += test-bz1744377
+check_PROGRAMS += test-issue180
+test_issue180_LDADD = $(top_builddir)/src/libfontconfig.la
+TESTS += test-issue180
+
EXTRA_DIST=run-test.sh run-test-conf.sh $(LOG_COMPILER) $(TESTDATA) out.expected-long-family-names out.expected-no-long-family-names
-CLEANFILES=out out1 out2 fonts.conf out.expected
+CLEANFILES = \
+ fonts.conf \
+ out \
+ out1 \
+ out2 \
+ out.expected \
+ run*.log \
+ run*.trs \
+ test*.log \
+ test*.trs \
+ $(NULL)
-include $(top_srcdir)/git.mk
diff --git a/test/run-test.sh b/test/run-test.sh
index 2e00f79..4e5968b 100644
--- a/test/run-test.sh
+++ b/test/run-test.sh
@@ -82,7 +82,7 @@ export FONTCONFIG_FILE
dotest "Basic check"
prep
cp $FONT1 $FONT2 $FONTDIR
-if [ -n ${SOURCE_DATE_EPOCH:-} ]; then
+if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR
fi
check
@@ -90,7 +90,7 @@ check
dotest "With a subdir"
prep
cp $FONT1 $FONT2 $FONTDIR
-if [ -n ${SOURCE_DATE_EPOCH:-} ]; then
+if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR
fi
$FCCACHE $FONTDIR
@@ -100,7 +100,7 @@ dotest "Subdir with a cache file"
prep
mkdir $FONTDIR/a
cp $FONT1 $FONT2 $FONTDIR/a
-if [ -n ${SOURCE_DATE_EPOCH:-} ]; then
+if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR/a
fi
$FCCACHE $FONTDIR/a
@@ -113,11 +113,11 @@ mkdir $FONTDIR/a/a
mkdir $FONTDIR/b
mkdir $FONTDIR/b/a
cp $FONT1 $FONTDIR/a
-if [ -n ${SOURCE_DATE_EPOCH:-} ]; then
+if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR/a
fi
cp $FONT2 $FONTDIR/b/a
-if [ -n ${SOURCE_DATE_EPOCH:-} ]; then
+if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR/b/a
fi
check
@@ -156,7 +156,7 @@ if [ x"$BWRAP" != "x" -a "x$EXEEXT" = "x" ]; then
dotest "Basic functionality with the bind-mounted cache dir"
prep
cp $FONT1 $FONT2 $FONTDIR
-if [ -n ${SOURCE_DATE_EPOCH:-} ]; then
+if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR
fi
$FCCACHE $FONTDIR
@@ -198,7 +198,7 @@ rm -rf $TESTTMPDIR out1 out2 xxx flist1 flist2 bind-fonts.conf
dotest "Different directory content between host and sandbox"
prep
cp $FONT1 $FONTDIR
-if [ -n ${SOURCE_DATE_EPOCH:-} ]; then
+if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR
fi
$FCCACHE $FONTDIR
@@ -208,7 +208,7 @@ stat -c '%n %s %y %z' `cat out1` > stat1
TESTTMPDIR=`mktemp -d /tmp/fontconfig.XXXXXXXX`
TESTTMP2DIR=`mktemp -d /tmp/fontconfig.XXXXXXXX`
cp $FONT2 $TESTTMP2DIR
-if [ -n ${SOURCE_DATE_EPOCH:-} ]; then
+if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $TESTTMP2DIR
fi
sed "s!@FONTDIR@!$TESTTMPDIR/fonts</dir><dir salt="'"'"salt-to-make-different"'"'">$FONTDIR!
@@ -251,7 +251,7 @@ dotest "Check consistency of MD5 in cache name"
prep
mkdir -p $FONTDIR/sub
cp $FONT1 $FONTDIR/sub
-if [ -n ${SOURCE_DATE_EPOCH:-} ]; then
+if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR/sub
fi
$FCCACHE $FONTDIR
@@ -278,7 +278,7 @@ rm -rf $TESTTMPDIR out1 out2 bind-fonts.conf
dotest "Fallback to uuid"
prep
cp $FONT1 $FONTDIR
-if [ -n ${SOURCE_DATE_EPOCH:-} ]; then
+if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR
fi
touch -d @`stat -c %Y $FONTDIR` $FONTDIR
@@ -321,7 +321,7 @@ mkdir -p $MyPWD/sysroot/$FONTDIR
mkdir -p $MyPWD/sysroot/$CACHEDIR
mkdir -p $MyPWD/sysroot/$MyPWD
cp $FONT1 $MyPWD/sysroot/$FONTDIR
-if [ -n ${SOURCE_DATE_EPOCH:-} ]; then
+if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $MyPWD/sysroot/$FONTDIR
fi
cp $MyPWD/fonts.conf $MyPWD/sysroot/$MyPWD/fonts.conf
diff --git a/test/test-issue180.c b/test/test-issue180.c
new file mode 100644
index 0000000..18a28d7
--- /dev/null
+++ b/test/test-issue180.c
@@ -0,0 +1,73 @@
+/*
+ * fontconfig/test/test-issue180.c
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the author(s) not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The authors make no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <fontconfig/fontconfig.h>
+
+int
+main (void)
+{
+ const FcChar8 *doc = ""
+ "<fontconfig>\n"
+ " <cachedir></cachedir>\n"
+ "</fontconfig>\n"
+ "";
+ const FcChar8 *doc2 = ""
+ "<fontconfig>\n"
+ " <cachedir prefix=\"xdg\"></cachedir>\n"
+ "</fontconfig>\n"
+ "";
+ FcConfig *cfg = FcConfigCreate ();
+ FcStrList *l;
+ FcChar8 *p;
+
+ if (!FcConfigParseAndLoadFromMemory (cfg, doc, FcTrue))
+ {
+ fprintf (stderr, "Unable to load a config from memory.\n");
+ return 1;
+ }
+ l = FcConfigGetCacheDirs (cfg);
+ if ((p = FcStrListNext (l)) != NULL)
+ {
+ fprintf (stderr, "There was one or more cachedirs\n");
+ return 1;
+ }
+ FcConfigDestroy (cfg);
+ cfg = FcConfigCreate ();
+ if (!FcConfigParseAndLoadFromMemory (cfg, doc2, FcTrue))
+ {
+ fprintf (stderr, "Unable to load a config from memory (with prefix).\n");
+ return 1;
+ }
+ l = FcConfigGetCacheDirs (cfg);
+ if ((p = FcStrListNext (l)) != NULL)
+ {
+ fprintf (stderr, "There was one or more cachedirs (with prefix)\n");
+ return 1;
+ }
+
+ FcConfigDestroy (cfg);
+
+ return 0;
+}
More information about the Fontconfig
mailing list