Skip to content

Commit 54cb702

Browse files
committed
Only generate invalid zim related to title index if there is a title index.
1 parent cc11eba commit 54cb702

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

scripts/create_test_zimfiles

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -220,23 +220,26 @@ title_index=($($scriptdir/inspectzim --title_index small.zim|tail -n +2))
220220
title1_dirent_index=$(encode_uint32 $((title_index[0])))
221221
title2_dirent_index=$(encode_uint32 $((title_index[1])))
222222

223-
create_broken_zim_file invalid.outofbounds_first_title_entry.zim \
224-
"$bad_article_index" \
225-
$((title_ptr_pos))
226-
227-
create_broken_zim_file invalid.outofbounds_last_title_entry.zim \
228-
"$bad_article_index" \
229-
$((title_ptr_pos+4*(article_count-1)))
230-
231-
create_broken_zim_file invalid.outofbounds_titleptrpos.zim \
232-
"$outofzimfile" \
233-
40
234-
235-
create_broken_zim_file invalid.nonsorted_title_index.zim \
236-
"$title2_dirent_index" \
237-
$((title_ptr_pos)) \
238-
"$title1_dirent_index" \
239-
$((title_ptr_pos+4))
223+
if [[ $title_ptr_pos != 0 ]]
224+
then
225+
create_broken_zim_file invalid.outofbounds_first_title_entry.zim \
226+
"$bad_article_index" \
227+
$((title_ptr_pos))
228+
229+
create_broken_zim_file invalid.outofbounds_last_title_entry.zim \
230+
"$bad_article_index" \
231+
$((title_ptr_pos+4*(article_count-1)))
232+
233+
create_broken_zim_file invalid.outofbounds_titleptrpos.zim \
234+
"$outofzimfile" \
235+
40
236+
237+
create_broken_zim_file invalid.nonsorted_title_index.zim \
238+
"$title2_dirent_index" \
239+
$((title_ptr_pos)) \
240+
"$title1_dirent_index" \
241+
$((title_ptr_pos+4))
242+
fi
240243

241244
bad_mimetype_list=$(printf '%-1968s' 'This is a bad mimetype value filling all the space between the header and the first cluster without any null character')
242245
create_broken_zim_file invalid.bad_mimetype_list.zim \

0 commit comments

Comments
 (0)