mirror of
https://github.com/kevinboone/epub2txt2
synced 2026-04-25 14:24:56 +02:00
Fixed bug in handling null metadata
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,4 +1,4 @@
|
||||
VERSION := 2.04
|
||||
VERSION := 2.05
|
||||
CC := gcc
|
||||
CFLAGS := -Wall -fPIC -fPIE
|
||||
LDFLAGS := -pie -s
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# epub2txt -- Extract text from EPUB documents
|
||||
|
||||
Version 2.04, April 2022
|
||||
Version 2.05, May 2022
|
||||
|
||||
## What is this?
|
||||
|
||||
@@ -232,6 +232,7 @@ even approximately, in ASCII.
|
||||
|
||||
Date | Change
|
||||
-----|-------
|
||||
2.05, Apr 2022 | Fixed bug with empty metadata tags
|
||||
2.04, Apr 2022 | Improved handling of UTF-8 BOMs
|
||||
2.03, Jan 2022 | Fixed a buffer overrun bug
|
||||
2.02, May 2020 | Updated XML parser
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
.\" redistribute this software so long as all of the original files are
|
||||
.\" included, and that this copyright notice is retained.
|
||||
.\"
|
||||
.TH epub2txt 1 "April 2022"
|
||||
.TH epub2txt 1 "May 2022"
|
||||
.SH NAME
|
||||
epub2txt \- Extract text from EPUB documents
|
||||
.SH SYNOPSIS
|
||||
|
||||
@@ -89,14 +89,22 @@ static char *epub2txt_unescape_html (const char *s)
|
||||
static void epub2txt_format_meta (const Epub2TxtOptions *options,
|
||||
const char *key, const char *text)
|
||||
{
|
||||
char *ss = epub2txt_unescape_html (text);
|
||||
char *s;
|
||||
asprintf (&s, "%s: %s", key, ss);
|
||||
char *error = NULL;
|
||||
xhtml_utf8_to_stdout (s, options, &error);
|
||||
if (error) free (error);
|
||||
free (s);
|
||||
free (ss);
|
||||
// text ends up "null" here, if the meta tag had no content (which should
|
||||
// not happen, but we don't want to crash if it does). I suppress all
|
||||
// output in this case, but perhaps it would be better to print the
|
||||
// metadata key, and the value "null", or "empty"? I can't really predict
|
||||
// what a user would prefer to see.
|
||||
if (text)
|
||||
{
|
||||
char *ss = epub2txt_unescape_html (text);
|
||||
char *s;
|
||||
asprintf (&s, "%s: %s", key, ss);
|
||||
char *error = NULL;
|
||||
xhtml_utf8_to_stdout (s, options, &error);
|
||||
if (error) free (error);
|
||||
free (s);
|
||||
free (ss);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user