From db6332110ee1fa475515cfee88c57d5d0aa9ce1d Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sun, 8 May 2005 17:59:07 +0000 Subject: More trusted checks. 2005-05-08 Christian Persch * embed/mozilla/EphyBrowser.cpp: * embed/mozilla/EventContext.cpp: More trusted checks. --- ChangeLog | 7 +++++++ embed/mozilla/EphyBrowser.cpp | 18 ++++++++++++++++++ embed/mozilla/EventContext.cpp | 18 ++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/ChangeLog b/ChangeLog index f98d50c0a..e8792c130 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-05-08 Christian Persch + + * embed/mozilla/EphyBrowser.cpp: + * embed/mozilla/EventContext.cpp: + + More trusted checks. + 2005-05-07 Christian Persch * src/ephy-lockdown.c: diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp index 257624e95..0f70367a3 100644 --- a/embed/mozilla/EphyBrowser.cpp +++ b/embed/mozilla/EphyBrowser.cpp @@ -133,6 +133,15 @@ EphyEventListener::Init (EphyBrowser *aOwner) NS_IMETHODIMP EphyDOMLinkEventListener::HandleEvent (nsIDOMEvent* aDOMEvent) { +#ifdef MOZ_NSIDOMNSEVENT_GETISTRUSTED + /* make sure the event is trusted */ + nsCOMPtr nsEvent (do_QueryInterface (aDOMEvent)); + NS_ENSURE_TRUE (nsEvent, NS_ERROR_FAILURE); + PRBool isTrusted = PR_FALSE; + nsEvent->GetIsTrusted (&isTrusted); + if (!isTrusted) return NS_OK; +#endif /* MOZ_NSIDOMNSEVENT_GETISTRUSTED */ + nsCOMPtr eventTarget; aDOMEvent->GetTarget(getter_AddRefs(eventTarget)); @@ -303,6 +312,15 @@ EphyDOMLinkEventListener::GetDocURI (nsIDOMElement *aElement, NS_IMETHODIMP EphyPopupBlockEventListener::HandleEvent (nsIDOMEvent * aDOMEvent) { +#ifdef MOZ_NSIDOMNSEVENT_GETISTRUSTED + /* make sure the event is trusted */ + nsCOMPtr nsEvent (do_QueryInterface (aDOMEvent)); + NS_ENSURE_TRUE (nsEvent, NS_ERROR_FAILURE); + PRBool isTrusted = PR_FALSE; + nsEvent->GetIsTrusted (&isTrusted); + if (!isTrusted) return NS_OK; +#endif /* MOZ_NSIDOMNSEVENT_GETISTRUSTED */ + nsCOMPtr popupEvent = do_QueryInterface (aDOMEvent); NS_ENSURE_TRUE (popupEvent, NS_ERROR_FAILURE); diff --git a/embed/mozilla/EventContext.cpp b/embed/mozilla/EventContext.cpp index d8bbf4fcb..1ac345b5b 100644 --- a/embed/mozilla/EventContext.cpp +++ b/embed/mozilla/EventContext.cpp @@ -667,6 +667,13 @@ nsresult EventContext::GetMouseEventInfo (nsIDOMMouseEvent *aMouseEvent, Mozilla nsCOMPtr nsEvent = do_QueryInterface(aMouseEvent); if (!nsEvent) return NS_ERROR_FAILURE; +#ifdef MOZ_NSIDOMNSEVENT_GETISTRUSTED + /* make sure the event is trusted */ + PRBool isTrusted = PR_FALSE; + nsEvent->GetIsTrusted (&isTrusted); + if (!isTrusted) return NS_ERROR_UNEXPECTED; +#endif /* MOZ_NSIDOMNSEVENT_GETISTRUSTED */ + nsresult rv; nsCOMPtr OriginalTarget; rv = nsEvent->GetOriginalTarget(getter_AddRefs(OriginalTarget)); @@ -718,6 +725,17 @@ nsresult EventContext::GetMouseEventInfo (nsIDOMMouseEvent *aMouseEvent, Mozilla nsresult EventContext::GetKeyEventInfo (nsIDOMKeyEvent *aKeyEvent, MozillaEmbedEvent *info) { +#ifdef MOZ_NSIDOMNSEVENT_GETISTRUSTED + /* make sure the event is trusted */ + nsCOMPtr nsEvent (do_QueryInterface (aKeyEvent)); + NS_ENSURE_TRUE (nsEvent, NS_ERROR_FAILURE); + + PRBool isTrusted = PR_FALSE; + nsEvent->GetIsTrusted (&isTrusted); + if (!isTrusted) return NS_ERROR_UNEXPECTED; +#endif /* MOZ_NSIDOMNSEVENT_GETISTRUSTED */ + + info->button = 0; nsresult rv; -- cgit v1.2.3