From a14a7a0ccc9de76aeab0b2e4bbf58f1a79deedc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 3 Jul 2024 10:19:30 +0200 Subject: New upstream version 5.3.0GA --- app/wlib/gtklib/browserhelp.c | 65 +++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 27 deletions(-) (limited to 'app/wlib/gtklib/browserhelp.c') diff --git a/app/wlib/gtklib/browserhelp.c b/app/wlib/gtklib/browserhelp.c index 7d45ea5..6d2ac5d 100644 --- a/app/wlib/gtklib/browserhelp.c +++ b/app/wlib/gtklib/browserhelp.c @@ -17,12 +17,13 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include +#include //#include "misc.h" @@ -45,7 +46,8 @@ extern wBool_t CheckHelpTopicExists(const char * topic); "variable.\n Also make sure that the user has sufficient access rights to read these" \ "files." /** - * Create a fully qualified url from a topic + * Create a fully qualified url from a topic. The library path is converted to + * an absolute path first. The url is then created from that path. * * \param helpUrl OUT pointer to url, free by caller * \param topic IN the help topic @@ -54,20 +56,29 @@ extern wBool_t CheckHelpTopicExists(const char * topic); static void TopicToUrl(char **helpUrl, const char *topic) { - DynString url; - DynStringMalloc(&url, 16); - - // build up the url line - DynStringCatCStrs(&url, - "file://", - wGetAppLibDir(), - "/html/", - topic, - ".html", - NULL); - - *helpUrl = strdup(DynStringToCStr(&url)); - DynStringFree(&url); + DynString url; + DynStringMalloc(&url, 16); + char *realPath; + + realPath = realpath(wGetAppLibDir(), NULL); + + if(realPath) { + // build up the url line + DynStringCatCStrs(&url, + "file://", + realPath, + "/html/", + topic, + ".html", + NULL); + + *helpUrl = strdup(DynStringToCStr(&url)); + DynStringFree(&url); + free(realPath); + } else { + wNoticeEx( NT_ERROR, _("Not enough memory for realpath()"), _("Exit"), NULL); + wExit(0); + } } /** * Invoke the system's default browser to display help for . First the @@ -79,22 +90,22 @@ TopicToUrl(char **helpUrl, const char *topic) void wHelp(const char * topic) { - int rc; - char *url; - char *currentPath; + int rc; + char *url; +// char *currentPath; - assert(topic != NULL); - assert(strlen(topic)); + assert(topic != NULL); + assert(strlen(topic)); - if (!CheckHelpTopicExists(topic)) return; - - TopicToUrl(&url, topic); + if (!CheckHelpTopicExists(topic)) { return; } + TopicToUrl(&url, topic); + printf(">%s<\n", url); rc = wOpenFileExternal(url); if (!rc) { - wNotice(HELPERRORTEXT, _("Cancel"), NULL); - } + wNotice(HELPERRORTEXT, _("Cancel"), NULL); + } - free(url); + free(url); } -- cgit v1.2.3