New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Threw a bug when I tried to make a link out of '-->' (User error?) #1794
Comments
Can confirm, not a user error; can be reproduced with any string that "reduces to an empty string" by makeValidPageName, eg. |
While the fix makes
Since one can create these invalid links via other means, eg. editing page source, I'd consider that a separate issue whose fix would be showing an error dialog like the one shown with links to non-existing anchors. |
Haven't looked into zim.errors.exception_handler, but here's a quick mock of a patch diff --git a/zim/gui/pageview/__init__.py b/zim/gui/pageview/__init__.py
index 83c63c42..57a67568 100644
--- a/zim/gui/pageview/__init__.py
+++ b/zim/gui/pageview/__init__.py
@@ -6511,6 +6511,8 @@ class PageView(GSignalEmitterMixin, Gtk.VBox):
def do_activate_link(self, link, hints):
try:
self._do_activate_link(link, hints)
+ except ValueError:
+ ErrorDialog(self, _('Invalid link: "%s"') % link).run() # T: error when invalid link clicked
except:
zim.errors.exception_handler(
'Exception during activate-link(%r)' % ((link, hints),)) |
To Reproduce
Steps to reproduce the behavior:
As the error says: "raise ValueError('Not a valid page name: %s (was: %s)' % (newname, name))
ValueError: Not a valid page name: (was: →)"
Environment (please complete the following information):
./zim.py
)Traceback
`This is zim 0.74.3
Platform: posix (Manjaro 21.1)
Locale: en_CA UTF-8
FS encoding: utf-8
Python: (3, 9, 7, 'final', 0)
PyGObject: (3, 42, 0)
======= Traceback =======
File "/home/tim/Downloads/Linux/Zim/zim-desktop-wiki-master/zim/actions.py", line 159, in _on_activate
self.call()
File "/home/tim/Downloads/Linux/Zim/zim-desktop-wiki-master/zim/actions.py", line 130, in call
return self._action.func(self._instance, *args, **kwargs)
File "/home/tim/Downloads/Linux/Zim/zim-desktop-wiki-master/zim/gui/pageview/init.py", line 7144, in insert_link
InsertLinkDialog(self, self).run()
File "/home/tim/Downloads/Linux/Zim/zim-desktop-wiki-master/zim/gui/pageview/init.py", line 8068, in init
self._text_for_link = self._link_to_text(href)
File "/home/tim/Downloads/Linux/Zim/zim-desktop-wiki-master/zim/gui/pageview/init.py", line 8122, in _link_to_text
parts = HRef.new_from_wiki_link(link).parts()
File "/home/tim/Downloads/Linux/Zim/zim-desktop-wiki-master/zim/notebook/page.py", line 360, in new_from_wiki_link
names = Path.makeValidPageName(href.lstrip('+')) if href else ""
File "/home/tim/Downloads/Linux/Zim/zim-desktop-wiki-master/zim/notebook/page.py", line 157, in makeValidPageName
raise ValueError('Not a valid page name: %s (was: %s)' % (newname, name))
ValueError: Not a valid page name: (was: →)`
The text was updated successfully, but these errors were encountered: