summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorLuigi Scarso <luigi.scarso@gmail.com>2023-02-18 17:30:30 +0000
committerLuigi Scarso <luigi.scarso@gmail.com>2023-02-18 17:30:30 +0000
commitf36b4fb123245249867a2756d84a49b4ff222c0d (patch)
treeae35f64028eac2b0e94fa7dd55b66bab57489fbe /Build
parentb677f4aad3313d6f43142e1ae7ca8481bfb817e6 (diff)
Fixed the "Invalid unicode ranges in CMap beginbfrange operator bug" as in pdfTeX (Hàn Thế Thành)
git-svn-id: svn://tug.org/texlive/trunk@65872 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/web2c/luatexdir/ChangeLog4
-rw-r--r--Build/source/texk/web2c/luatexdir/font/tounicode.c18
-rw-r--r--Build/source/texk/web2c/luatexdir/luatex_svnversion.h2
3 files changed, 21 insertions, 3 deletions
diff --git a/Build/source/texk/web2c/luatexdir/ChangeLog b/Build/source/texk/web2c/luatexdir/ChangeLog
index 15bb53b736a..ba163208a80 100644
--- a/Build/source/texk/web2c/luatexdir/ChangeLog
+++ b/Build/source/texk/web2c/luatexdir/ChangeLog
@@ -1,8 +1,10 @@
2023-02-18 Luigi Scarso <luigi.scarso@gmail.com>
+ * Fixed the "Invalid unicode ranges in CMap beginbfrange operator bug" as in pdfTeX (Hàn Thế Thành)
+
+2023-02-18 Luigi Scarso <luigi.scarso@gmail.com>
* new "late special" feature by Phelype Oleinik,
heavily adapted by H.Hagen.
-
2023-02-05 Luigi Scarso <luigi.scarso@gmail.com>
* Fix typos (thanks to J. Friedrich)
diff --git a/Build/source/texk/web2c/luatexdir/font/tounicode.c b/Build/source/texk/web2c/luatexdir/font/tounicode.c
index b1e08e7cebd..68b6e01fd7e 100644
--- a/Build/source/texk/web2c/luatexdir/font/tounicode.c
+++ b/Build/source/texk/web2c/luatexdir/font/tounicode.c
@@ -305,6 +305,21 @@ static void set_cid_glyph_unicode(long index, glyph_unicode_entry * gp, internal
}
*/
+static boolean is_last_byte_valid(int srcCode1, int srcCode2, long code)
+{
+ /*tex
+ Followin pdfTeX, when defining ranges of this type, the value of the last byte in the
+ string shall be less than or equal to 255 − (srcCode2 − srcCode1). This
+ ensures that the last byte of the string shall not be incremented past
+ 255; otherwise, the result of mapping is undefined.
+ */
+ char *s = strend(utf16be_str(code)) - 2;
+ long l = strtol(s, NULL, 16);
+ return l < 255 - (srcCode2 - srcCode1);
+}
+
+
+
static int do_write_tounicode(PDF pdf, char **glyph_names, char *name, internal_font_number f)
{
char buf[SMALL_BUF_SIZE], *p, *s;
@@ -403,7 +418,8 @@ static int do_write_tounicode(PDF pdf, char **glyph_names, char *name, internal_
} else {
/*tex |gtab[i].code >= 0| */
j = i;
- while (i < 256 && gtab[i + 1].code >= 0 && gtab[i].code + 1 == gtab[i + 1].code)
+ while (i < 256 && gtab[i + 1].code >= 0 && gtab[i].code + 1 == gtab[i + 1].code && is_last_byte_valid(j, i, gtab[i].code)
+)
i++;
/*tex
At this point |i| is the last entry of the subrange so we move |i| to
diff --git a/Build/source/texk/web2c/luatexdir/luatex_svnversion.h b/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
index a8e86fb4032..d900e530e2b 100644
--- a/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
+++ b/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
@@ -1,4 +1,4 @@
#ifndef luatex_svn_revision_h
#define luatex_svn_revision_h
-#define luatex_svn_revision 7559
+#define luatex_svn_revision 7560
#endif