* change_start_page(), LoadStartpage(): check whether the startpage is allowed by...
authorWilfried Göesgens <willi@citadel.org>
Thu, 8 Apr 2010 21:04:13 +0000 (21:04 +0000)
committerWilfried Göesgens <willi@citadel.org>
Thu, 8 Apr 2010 21:04:13 +0000 (21:04 +0000)
* InitModule_MSG() disallow postpart_download, postpart, confirm_move_msg, delete_msg, move_msg, post to become the startpage; they don't do usefull things there.

webcit/messages.c
webcit/preferences.c
webcit/webcit.h

index 33f3a8f0108d91eec69e8355bb3960e92aaa0d18..1ff718905649d336d38e2b1ef4d24581ebfb7718 100644 (file)
@@ -1729,10 +1729,10 @@ InitModule_MSG
        WebcitAddUrlHandler(HKEY("readlt"), "", 0, h_readlt, NEED_URL);
        WebcitAddUrlHandler(HKEY("do_search"), "", 0, h_do_search, 0);
        WebcitAddUrlHandler(HKEY("display_enter"), "", 0, display_enter, 0);
-       WebcitAddUrlHandler(HKEY("post"), "", 0, post_message, 0);
-       WebcitAddUrlHandler(HKEY("move_msg"), "", 0, move_msg, 0);
-       WebcitAddUrlHandler(HKEY("delete_msg"), "", 0, delete_msg, 0);
-       WebcitAddUrlHandler(HKEY("confirm_move_msg"), "", 0, confirm_move_msg, 0);
+       WebcitAddUrlHandler(HKEY("post"), "", 0, post_message, PROHIBIT_STARTPAGE);
+       WebcitAddUrlHandler(HKEY("move_msg"), "", 0, move_msg, PROHIBIT_STARTPAGE);
+       WebcitAddUrlHandler(HKEY("delete_msg"), "", 0, delete_msg, PROHIBIT_STARTPAGE);
+       WebcitAddUrlHandler(HKEY("confirm_move_msg"), "", 0, confirm_move_msg, PROHIBIT_STARTPAGE);
        WebcitAddUrlHandler(HKEY("msg"), "", 0, embed_message, NEED_URL);
        WebcitAddUrlHandler(HKEY("message"), "", 0, handle_one_message, NEED_URL|XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
        WebcitAddUrlHandler(HKEY("printmsg"), "", 0, print_message, NEED_URL);
@@ -1741,8 +1741,8 @@ InitModule_MSG
 
        WebcitAddUrlHandler(HKEY("mimepart"), "", 0, view_mimepart, NEED_URL);
        WebcitAddUrlHandler(HKEY("mimepart_download"), "", 0, download_mimepart, NEED_URL);
-       WebcitAddUrlHandler(HKEY("postpart"), "", 0, view_postpart, NEED_URL);
-       WebcitAddUrlHandler(HKEY("postpart_download"), "", 0, download_postpart, NEED_URL);
+       WebcitAddUrlHandler(HKEY("postpart"), "", 0, view_postpart, NEED_URL|PROHIBIT_STARTPAGE);
+       WebcitAddUrlHandler(HKEY("postpart_download"), "", 0, download_postpart, NEED_URL|PROHIBIT_STARTPAGE);
 
        /* json */
        WebcitAddUrlHandler(HKEY("roommsgs"), "", 0, jsonMessageList,0);
index a00c732936f6f5fee7223ca6ef167aa21433b142..1891beae4cfe1c41294904bb7e35067104aa8ba6 100644 (file)
@@ -10,6 +10,7 @@
 #include "groupdav.h"
 
 HashList *PreferenceHooks;
+extern HashList *HandlerHash;
 
 typedef struct _PrefDef {
        long Type;
@@ -984,23 +985,50 @@ void offer_start_page(StrBuf *Target, WCTemplputParams *TP)
  */
 void change_start_page(void) 
 {
-       if (!havebstr("startpage")) {
+       wcsession *WCC = WC;
+       const char *pch;
+       void *vHandler;
+       int ProhibitSave = 0;
+       const StrBuf *pStartPage = sbstr("startpage");
+
+       if (pStartPage != NULL) {
+               pch = strchr(ChrPtr(pStartPage), '?');
+
+               if ((pch != NULL) && (
+                           GetHash(HandlerHash, ChrPtr(pStartPage), pch - ChrPtr(pStartPage), &vHandler), 
+                           (vHandler != NULL) &&
+                           ((((WebcitHandler*)vHandler)->Flags & PROHIBIT_STARTPAGE) != 0)))
+               { /* OK, This handler doesn't want to be set as start page, prune it. */
+                       ProhibitSave = 1;
+               }
+       }
+
+       if ((pStartPage == NULL) || 
+           (ProhibitSave == 1))
+       {
                set_preference_backend(HKEY("startpage"), 
                                       0, 
                                       NewStrBufPlain(HKEY("")),
                                       PRF_STRING,
                                       1, 
                                       NULL);
-               safestrncpy(WC->ImportantMessage,
-                           _("You no longer have a start page selected."),
-                           sizeof( WC->ImportantMessage));
+               if (ProhibitSave == 1)
+                       StrBufAppendBufPlain(WCC->ImportantMsg,
+                                            _("This isn't allowed to become the start page."),
+                                            -1, 0);
+               else
+                       StrBufAppendBufPlain(WCC->ImportantMsg,
+                                            _("You no longer have a start page selected."),
+                                            -1, 0);
                display_main_menu();
                return;
        }
 
+
+
        set_preference_backend(HKEY("startpage"), 
                               0, 
-                              NewStrBufDup(sbstr("startpage")),
+                              NewStrBufDup(pStartPage),
                               PRF_STRING,
                               1, 
                               NULL);
@@ -1014,6 +1042,7 @@ void change_start_page(void)
 void LoadStartpage(StrBuf *URL, long lvalue)
 {
        const char *pch;
+       void *vHandler;
        pch = strchr(ChrPtr(URL), '?');
        if (pch == NULL) {
                /* purge the sins of the past... */
@@ -1023,6 +1052,13 @@ void LoadStartpage(StrBuf *URL, long lvalue)
                        WC->SavePrefsToServer = 1;
                }
        }
+       else if (GetHash(HandlerHash, ChrPtr(URL), pch - ChrPtr(URL), &vHandler), 
+                (vHandler != NULL) &&
+                ((((WebcitHandler*)vHandler)->Flags & PROHIBIT_STARTPAGE) != 0))
+       { /* OK, This handler doesn't want to be set as start page, prune it. */
+               FlushStrBuf(URL);
+               WC->SavePrefsToServer = 1;
+       }
 }
 
 
index b65683c9c2ab0dae5d6c9b59db745e1a392715d0..385f9f57354d9ad3615bb5ed931c7927380c2570 100644 (file)
@@ -346,6 +346,7 @@ typedef struct _addrbookent {
 #define ISSTATIC (1<<7)
 #define FORCE_SESSIONCLOSE (1<<8)
 #define PARSE_REST_URL (1<<9)
+#define PROHIBIT_STARTPAGE (1<<10)
 
 typedef void (*WebcitHandlerFunc)(void);
 typedef struct  _WebcitHandler{