When an EPUB contains elements with custom namespace prefixes (e.g.
<vita:metadata>), the remove_namespaces method in the KF8 writer
crashes with `ValueError: Invalid tag name 'vita:'`.
The existing except ValueError block only strips colons from attribute
names but does not handle the tag name itself. This causes the second
makeelement call to raise the same ValueError.
Fix: replace colons with hyphens in the tag name before retrying,
consistent with how colon-containing attributes are already handled.
Since version 9.6.0, pressing `v` in the FTS search result pane results in
the following error:
```
Traceback (most recent call last):
File "/usr/lib/calibre/calibre/gui2/fts/dialog.py", line 32, in view_current_book
if not self.results_panel.view_current_result():
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/lib/calibre/calibre/gui2/fts/search.py", line 1062, in view_current_result
open_book(results, match)
~~~~~~~~~^^^^^^^^^^^^^^^^
File "/usr/lib/calibre/calibre/gui2/fts/search.py", line 115, in open_book
result_dict = results.result_dicts[match_index]
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
TypeError: list indices must be integers or slices, not dict
```
I traced this back to commit b10e56d9e5 (Refactor FTS dialog to allow multiple
result visualisations) which refactored `ResultsView.view_current_result` in
`src/calibre/gui2/fts/search.py` from:
``` python
def view_current_result(self):
idx = self.currentIndex()
if idx.isValid():
results, match = self.m.data_for_index(idx)
if results:
if match is not None:
match = idx.row()
open_book(results, match)
return True
return False
```
to `ResultsPanel.view_current_result`:
``` python
def view_current_result(self):
results, match = self.current_view.current_result()
if results:
open_book(results, match)
return True
return False
```
and `SplitView.current_result`:
``` python
def current_result(self):
idx = self.results_view.currentIndex()
if idx.isValid():
results, match = self.results_view.model().data_for_index(idx)
if match is None:
match = idx.row()
return results, match
return None, None
```
As can be seen in the latter, the condition in the original
`ResultsView.view_current_result`:
``` python
if match is not None:
match = idx.row()
```
has changed to:
``` python
if match is None:
match = idx.row()
```
in `SplitView.current_result` which is causing the error.
This bug is fixed in the current commit.
o my kindle colorsoft has a ton of books on it, so I'm guessing
that that is why this crashed popped up.
o there were cases in this file of doing the memory clean up safely,
so I just copied how it was done there.
This is invalid, but there apparently exist some books in the wild that
use it. Sigh. See #2146609 (*LOTS* of undesired splits on EPUB to AZW3 conversion)