shithub: pdffs

Download patch

ref: 73b21f1bdadc28eddee84ae0a4c70f7ec3bd29ed
parent: 97218f13586cad7be42bdd1ce28072d10df1c2f9
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Aug 27 07:00:42 EDT 2020

pdfstring: octal chars

--- a/string.c
+++ b/string.c
@@ -40,7 +40,8 @@
 pdfstring(char *p, char **e, int len)
 {
 	Rune r;
-	int c, i, o, n, paren;
+	int c, j, i, o, n, paren;
+	char oct[4];
 
 	if(len < 2){
 		werrstr("too short");
@@ -80,10 +81,12 @@
 				goto err;
 			}
 			if(r >= '0' && r <= '9'){ /* octal */
-				werrstr("octal chars not implemented"); /* FIXME */
-				goto err;
-			}
-			if(r >= nelem(esc) || (c = esc[r]) == 0){
+				n = 0;
+				for(j = 0; j < 3 && i < len && p[i] >= '0' && p[i] <= '9'; j++, i++)
+					oct[j] = p[i];
+				oct[j] = 0;
+				c = strtol(oct, nil, 8);
+			}else if(r >= nelem(esc) || (c = esc[r]) == 0){
 				werrstr("unknown escape char at byte %d", i);
 				goto err;
 			}
@@ -134,6 +137,9 @@
 	{"(non-closed paren",      17, nil,             -1},
 	{"wrong first char",       16, nil,             -1},
 	{"(parens((()((())))()))", 22, "parens",         6},
+	{"(\\0053)",                7, "\x053",          2},
+	{"(\\053)",                 6, "+",              1},
+	{"(\\53)",                  5, "+",              1},
 	{"()",                      2, "",               0},
 	{")",                       1, nil,             -1},
 	{"(\\)\\()",                6, ")(",             2},