summaryrefslogtreecommitdiff
path: root/source/tools
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2017-02-04 19:29:01 +0100
committerSebastian Rasmussen <sebras@gmail.com>2017-02-06 14:30:02 +0100
commit931f3d9a6c3ab0fbfa3e365fe040e1b86c47e9fc (patch)
tree48a524036dea3d7af27675be46d31c6db8270c74 /source/tools
parentf7d19a9ce048f0712b91ca1759a008e7e989644a (diff)
downloadmupdf-931f3d9a6c3ab0fbfa3e365fe040e1b86c47e9fc.tar.xz
Be stricter when parsing OCG selections in mudraw.
This avoids allowing 0,z as a valid selection.
Diffstat (limited to 'source/tools')
-rw-r--r--source/tools/mudraw.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c
index 720e7ffc..2bcf989e 100644
--- a/source/tools/mudraw.c
+++ b/source/tools/mudraw.c
@@ -1192,14 +1192,14 @@ static void bgprint_worker(void *arg)
static inline int iswhite(int ch)
{
return
- ch == '\000' || ch == '\011' || ch == '\012' ||
+ ch == '\011' || ch == '\012' ||
ch == '\014' || ch == '\015' || ch == '\040';
}
static void apply_layer_config(fz_context *ctx, fz_document *doc, const char *lc)
{
pdf_document *pdoc = pdf_specifics(ctx, doc);
- int config;
+ int config = -1;
int n, j;
pdf_layer_config info;
@@ -1230,31 +1230,36 @@ static void apply_layer_config(fz_context *ctx, fz_document *doc, const char *lc
return;
}
- if (*lc < '0' || *lc > '9')
- {
- fprintf(stderr, "-y expects a comma separated list of numbers, or 'l' to list layer configs\n");
- return;
- }
- config = fz_atoi(lc);
- pdf_select_layer_config(ctx, pdoc, config);
-
- /* Make any alterations to the state required */
- while (1)
+ while (*lc)
{
int i;
+ if (*lc < '0' || *lc > '9')
+ {
+ fprintf(stderr, "cannot find number expected for -y\n");
+ return;
+ }
+ i = fz_atoi(lc);
+ pdf_select_layer_config(ctx, pdoc, i);
+
+ if (config < 0)
+ config = i;
+
while (*lc >= '0' && *lc <= '9')
lc++;
while (iswhite(*lc))
lc++;
- if (*lc != ',')
- break;
- lc++;
- while (iswhite(*lc))
+ if (*lc == ',')
+ {
lc++;
- i = fz_atoi(lc);
-
- pdf_toggle_layer_config_ui(ctx, pdoc, i);
+ while (iswhite(*lc))
+ lc++;
+ }
+ else if (*lc)
+ {
+ fprintf(stderr, "cannot find comma expected for -y\n");
+ return;
+ }
}
/* Now list the final state of the config */