Changeset 28565 in webkit
- Timestamp:
- Dec 8, 2007 10:03:43 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r28551 r28565 1 2007-12-07 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Darin. 4 5 - Rename isSafeScript to allowsAccess. 6 7 * bindings/NP_jsobject.cpp: 8 (_isSafeScript): 9 * kjs/JSGlobalObject.h: 10 (KJS::JSGlobalObject::allowsAccessFrom): Reverse caller/argument of allowsAccessFrom to match 11 the new call. 12 1 13 2007-12-07 Geoffrey Garen <ggaren@apple.com> 2 14 -
trunk/JavaScriptCore/bindings/NP_jsobject.cpp
r28468 r28565 79 79 if (!obj->originRootObject || !obj->rootObject) 80 80 return true; 81 81 82 82 if (!obj->originRootObject->isValid() || !obj->rootObject->isValid()) 83 83 return false; 84 85 return obj-> originRootObject->globalObject()->isSafeScript(obj->rootObject->globalObject());84 85 return obj->rootObject->globalObject()->allowsAccessFrom(obj->originRootObject->globalObject()); 86 86 } 87 87 -
trunk/JavaScriptCore/kjs/JSGlobalObject.h
r28527 r28565 223 223 virtual bool shouldInterruptScript() const { return true; } 224 224 225 virtual bool isSafeScript(const JSGlobalObject*) const { return true; }225 virtual bool allowsAccessFrom(const JSGlobalObject*) const { return true; } 226 226 227 227 private: -
trunk/WebCore/ChangeLog
r28563 r28565 1 2007-12-07 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Darin. 4 5 - Removes the faulty isSafeScript implementation that was only 6 used for plugins. 7 - Renames isSafeScript to allowsAccessFrom. 8 9 * bindings/js/JSDOMWindowCustom.cpp: 10 (WebCore::JSDOMWindow::customGetOwnPropertySlot): 11 (WebCore::JSDOMWindow::customPut): 12 * bindings/js/kjs_dom.cpp: 13 (WebCore::checkNodeSecurity): 14 * bindings/js/kjs_window.cpp: 15 (KJS::createWindow): 16 (KJS::Window::getValueProperty): 17 (KJS::Window::namedItemGetter): 18 (KJS::Window::getOwnPropertySlot): 19 (KJS::Window::put): 20 (KJS::Window::allowsAccessFrom): 21 (KJS::Window::setListener): 22 (KJS::Window::getListener): 23 (KJS::WindowProtoFuncOpen::callAsFunction): 24 (KJS::WindowProtoFuncSetTimeout::callAsFunction): 25 (KJS::WindowProtoFuncClearTimeout::callAsFunction): 26 (KJS::WindowProtoFuncSetInterval::callAsFunction): 27 (KJS::WindowProtoFuncAddEventListener::callAsFunction): 28 (KJS::WindowProtoFuncRemoveEventListener::callAsFunction): 29 (KJS::WindowProtoFuncNotImplemented::callAsFunction): 30 (KJS::Location::getOwnPropertySlot): 31 (KJS::Location::put): 32 (KJS::LocationProtoFuncReplace::callAsFunction): 33 (KJS::LocationProtoFuncReload::callAsFunction): 34 (KJS::LocationProtoFuncAssign::callAsFunction): 35 (KJS::LocationProtoFuncToString::callAsFunction): 36 * bindings/js/kjs_window.h: 37 (KJS::Window::allowsAccessFrom): 38 * bindings/objc/WebScriptObject.mm: 39 (-[WebScriptObject _isSafeScript]): Reverse caller/argument of allowsAccessFrom to match 40 the new call. 41 * bindings/scripts/CodeGeneratorJS.pm: 42 1 43 2007-12-08 Rob Buis <buis@kde.org> 2 44 -
trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp
r27608 r28565 57 57 KJS::JSValue** val = getDirectLocation(propertyName); 58 58 if (val) { 59 if (! isSafeScript(exec)) {59 if (!allowsAccessFrom(exec)) { 60 60 slot.setUndefined(this); 61 61 return true; … … 70 70 } 71 71 72 // FIXME: We need this to work around the blanket isSafeScriptcheck in KJS::Window. Once we remove that, we72 // FIXME: We need this to work around the blanket same origin (allowsAccessFrom) check in KJS::Window. Once we remove that, we 73 73 // can move this to JSDOMWindowPrototype. 74 74 KJS::JSValue* proto = prototype(); … … 82 82 slot.setStaticEntry(this, entry, KJS::staticFunctionGetter); 83 83 else { 84 if (! isSafeScript(exec))84 if (!allowsAccessFrom(exec)) 85 85 slot.setUndefined(this); 86 86 else … … 108 108 // We have a local override (e.g. "var location"), save time and jump directly to JSObject. 109 109 if (KJS::JSObject::getDirect(propertyName)) { 110 if ( isSafeScript(exec))110 if (allowsAccessFrom(exec)) 111 111 KJS::JSObject::put(exec, propertyName, value, attr); 112 112 return true; -
trunk/WebCore/bindings/js/kjs_dom.cpp
r28468 r28565 59 59 bool checkNodeSecurity(ExecState* exec, Node* n) 60 60 { 61 if (!n) 61 if (!n) 62 62 return false; 63 63 64 64 // Check to see if the currently executing interpreter is allowed to access the specified node 65 65 Window* win = Window::retrieveWindow(n->document()->frame()); 66 return win && win-> isSafeScript(exec);66 return win && win->allowsAccessFrom(exec); 67 67 } 68 68 -
trunk/WebCore/bindings/js/kjs_window.cpp
r28485 r28565 391 391 newWindow->putDirect("dialogArguments", dialogArgs); 392 392 393 if (!url.startsWith("javascript:", false) || newWindow-> isSafeScript(exec)) {393 if (!url.startsWith("javascript:", false) || newWindow->allowsAccessFrom(exec)) { 394 394 String completedURL = url.isEmpty() ? url : activeFrame->document()->completeURL(url); 395 395 bool userGesture = activeFrame->scriptProxy()->processingUserGesture(); … … 508 508 switch (token) { 509 509 case Crypto: 510 if (! isSafeScript(exec))510 if (!allowsAccessFrom(exec)) 511 511 return jsUndefined(); 512 512 return jsUndefined(); // FIXME: implement this 513 513 case DOMException: 514 if (! isSafeScript(exec))514 if (!allowsAccessFrom(exec)) 515 515 return jsUndefined(); 516 516 return getDOMExceptionConstructor(exec); 517 517 case Event_: 518 if (! isSafeScript(exec))518 if (!allowsAccessFrom(exec)) 519 519 return jsUndefined(); 520 520 if (!d->m_evt) … … 525 525 case Navigator_: 526 526 case ClientInformation: { 527 if (! isSafeScript(exec))527 if (!allowsAccessFrom(exec)) 528 528 return jsUndefined(); 529 529 // Store the navigator in the object so we get the same one each time. … … 536 536 } 537 537 case Image: 538 if (! isSafeScript(exec))538 if (!allowsAccessFrom(exec)) 539 539 return jsUndefined(); 540 540 // FIXME: this property (and the few below) probably shouldn't create a new object every … … 542 542 return new ImageConstructorImp(exec, impl()->frame()->document()); 543 543 case Option: 544 if (! isSafeScript(exec))544 if (!allowsAccessFrom(exec)) 545 545 return jsUndefined(); 546 546 return new JSHTMLOptionElementConstructor(exec, impl()->frame()->document()); 547 547 case XMLHttpRequest: 548 if (! isSafeScript(exec))548 if (!allowsAccessFrom(exec)) 549 549 return jsUndefined(); 550 550 return new JSXMLHttpRequestConstructorImp(exec, impl()->frame()->document()); … … 557 557 #if ENABLE(XSLT) 558 558 case XSLTProcessor_: 559 if (! isSafeScript(exec))559 if (!allowsAccessFrom(exec)) 560 560 return jsUndefined(); 561 561 return new XSLTProcessorConstructorImp(exec); … … 566 566 } 567 567 568 if (! isSafeScript(exec))568 if (!allowsAccessFrom(exec)) 569 569 return jsUndefined(); 570 570 … … 639 639 Window *thisObj = static_cast<Window *>(slot.slotBase()); 640 640 Document *doc = thisObj->impl()->frame()->document(); 641 ASSERT(thisObj-> isSafeScript(exec) && doc && doc->isHTMLDocument());641 ASSERT(thisObj->allowsAccessFrom(exec) && doc && doc->isHTMLDocument()); 642 642 643 643 String name = propertyName; … … 667 667 return false; 668 668 } 669 if ( isSafeScript(exec))669 if (allowsAccessFrom(exec)) 670 670 slot.setStaticEntry(this, entry, staticFunctionGetter); 671 671 else … … 690 690 Document* doc = impl()->frame()->document(); 691 691 if (doc && doc->isHTMLDocument()) { 692 if (! isSafeScript(exec)) {692 if (!allowsAccessFrom(exec)) { 693 693 slot.setUndefined(this); 694 694 return true; … … 702 702 } 703 703 704 if (! isSafeScript(exec)) {704 if (!allowsAccessFrom(exec)) { 705 705 slot.setUndefined(this); 706 706 return true; … … 715 715 if (entry) { 716 716 if (entry->attr & Function) { 717 if ( isSafeScript(exec))717 if (allowsAccessFrom(exec)) 718 718 JSObject::put(exec, propertyName, value, attr); 719 719 return; … … 729 729 return; 730 730 DeprecatedString dstUrl = p->loader()->completeURL(DeprecatedString(value->toString(exec))).url(); 731 if (!dstUrl.startsWith("javascript:", false) || isSafeScript(exec)) {731 if (!dstUrl.startsWith("javascript:", false) || allowsAccessFrom(exec)) { 732 732 bool userGesture = p->scriptProxy()->processingUserGesture(); 733 733 // We want a new history item if this JS was called via a user gesture … … 738 738 } 739 739 case Onabort: 740 if ( isSafeScript(exec))740 if (allowsAccessFrom(exec)) 741 741 setListener(exec, abortEvent,value); 742 742 return; 743 743 case Onblur: 744 if ( isSafeScript(exec))744 if (allowsAccessFrom(exec)) 745 745 setListener(exec, blurEvent,value); 746 746 return; 747 747 case Onchange: 748 if ( isSafeScript(exec))748 if (allowsAccessFrom(exec)) 749 749 setListener(exec, changeEvent,value); 750 750 return; 751 751 case Onclick: 752 if ( isSafeScript(exec))752 if (allowsAccessFrom(exec)) 753 753 setListener(exec,clickEvent,value); 754 754 return; 755 755 case Ondblclick: 756 if ( isSafeScript(exec))756 if (allowsAccessFrom(exec)) 757 757 setListener(exec, dblclickEvent,value); 758 758 return; 759 759 case Onerror: 760 if ( isSafeScript(exec))760 if (allowsAccessFrom(exec)) 761 761 setListener(exec, errorEvent, value); 762 762 return; 763 763 case Onfocus: 764 if ( isSafeScript(exec))764 if (allowsAccessFrom(exec)) 765 765 setListener(exec,focusEvent,value); 766 766 return; 767 767 case Onkeydown: 768 if ( isSafeScript(exec))768 if (allowsAccessFrom(exec)) 769 769 setListener(exec,keydownEvent,value); 770 770 return; 771 771 case Onkeypress: 772 if ( isSafeScript(exec))772 if (allowsAccessFrom(exec)) 773 773 setListener(exec,keypressEvent,value); 774 774 return; 775 775 case Onkeyup: 776 if ( isSafeScript(exec))776 if (allowsAccessFrom(exec)) 777 777 setListener(exec,keyupEvent,value); 778 778 return; 779 779 case Onload: 780 if ( isSafeScript(exec))780 if (allowsAccessFrom(exec)) 781 781 setListener(exec,loadEvent,value); 782 782 return; 783 783 case Onmousedown: 784 if ( isSafeScript(exec))784 if (allowsAccessFrom(exec)) 785 785 setListener(exec,mousedownEvent,value); 786 786 return; 787 787 case Onmousemove: 788 if ( isSafeScript(exec))788 if (allowsAccessFrom(exec)) 789 789 setListener(exec,mousemoveEvent,value); 790 790 return; 791 791 case Onmouseout: 792 if ( isSafeScript(exec))792 if (allowsAccessFrom(exec)) 793 793 setListener(exec,mouseoutEvent,value); 794 794 return; 795 795 case Onmouseover: 796 if ( isSafeScript(exec))796 if (allowsAccessFrom(exec)) 797 797 setListener(exec,mouseoverEvent,value); 798 798 return; 799 799 case Onmouseup: 800 if ( isSafeScript(exec))800 if (allowsAccessFrom(exec)) 801 801 setListener(exec,mouseupEvent,value); 802 802 return; 803 803 case OnWindowMouseWheel: 804 if ( isSafeScript(exec))804 if (allowsAccessFrom(exec)) 805 805 setListener(exec, mousewheelEvent,value); 806 806 return; 807 807 case Onreset: 808 if ( isSafeScript(exec))808 if (allowsAccessFrom(exec)) 809 809 setListener(exec,resetEvent,value); 810 810 return; 811 811 case Onresize: 812 if ( isSafeScript(exec))812 if (allowsAccessFrom(exec)) 813 813 setListener(exec,resizeEvent,value); 814 814 return; 815 815 case Onscroll: 816 if ( isSafeScript(exec))816 if (allowsAccessFrom(exec)) 817 817 setListener(exec,scrollEvent,value); 818 818 return; 819 819 case Onsearch: 820 if ( isSafeScript(exec))820 if (allowsAccessFrom(exec)) 821 821 setListener(exec,searchEvent,value); 822 822 return; 823 823 case Onselect: 824 if ( isSafeScript(exec))824 if (allowsAccessFrom(exec)) 825 825 setListener(exec,selectEvent,value); 826 826 return; 827 827 case Onsubmit: 828 if ( isSafeScript(exec))828 if (allowsAccessFrom(exec)) 829 829 setListener(exec,submitEvent,value); 830 830 return; 831 831 case Onbeforeunload: 832 if ( isSafeScript(exec))832 if (allowsAccessFrom(exec)) 833 833 setListener(exec, beforeunloadEvent, value); 834 834 return; 835 835 case Onunload: 836 if ( isSafeScript(exec))836 if (allowsAccessFrom(exec)) 837 837 setListener(exec, unloadEvent, value); 838 838 return; … … 841 841 } 842 842 } 843 if ( isSafeScript(exec))843 if (allowsAccessFrom(exec)) 844 844 JSObject::put(exec, propertyName, value, attr); 845 845 } 846 846 847 static bool shouldLoadAsEmptyDocument(const KURL &url) 848 { 849 return url.protocol().lower() == "about" || url.isEmpty(); 850 } 851 852 bool Window::isSafeScript(const JSGlobalObject *origin, const JSGlobalObject *target) 853 { 854 if (origin == target) 847 bool Window::allowsAccessFrom(const JSGlobalObject* other) const 848 { 849 const Frame* originFrame = static_cast<const Window*>(other)->impl()->frame(); 850 if (!originFrame) 851 return false; 852 853 const Frame* targetFrame = impl()->frame(); 854 if (!targetFrame) 855 return false; 856 857 if (originFrame == targetFrame) 855 858 return true; 856 859 857 Frame* originFrame = static_cast<const Window*>(origin)->impl()->frame(); 858 Frame* targetFrame = static_cast<const Window*>(target)->impl()->frame(); 860 WebCore::Document* targetDocument = targetFrame->document(); 859 861 860 862 // JS may be attempting to access the "window" object, which should be valid, 861 863 // even if the document hasn't been constructed yet. If the document doesn't 862 864 // exist yet allow JS to access the window object. 863 if (!target Frame->document())865 if (!targetDocument) 864 866 return true; 865 867 866 WebCore::Document *originDocument = originFrame->document(); 867 WebCore::Document *targetDocument = targetFrame->document(); 868 869 if (!targetDocument) { 870 return false; 871 } 872 873 WebCore::String targetDomain = targetDocument->domain(); 874 875 // Always allow local pages to execute any JS. 876 if (targetDomain.isNull()) 868 WebCore::Document* originDocument = originFrame->document(); 869 870 const SecurityOrigin& originSecurityOrigin = originDocument->securityOrigin(); 871 const SecurityOrigin& targetSecurityOrigin = targetDocument->securityOrigin(); 872 873 if (originSecurityOrigin.canAccess(targetSecurityOrigin)) 877 874 return true; 878 875 879 WebCore::String originDomain = originDocument->domain(); 880 881 // if this document is being initially loaded as empty by its parent 882 // or opener, allow access from any document in the same domain as 883 // the parent or opener. 884 if (shouldLoadAsEmptyDocument(targetFrame->loader()->url())) { 885 Frame* ancestorFrame = targetFrame->loader()->opener() ? targetFrame->loader()->opener() : targetFrame->tree()->parent(); 886 while (ancestorFrame && shouldLoadAsEmptyDocument(ancestorFrame->loader()->url())) 887 ancestorFrame = ancestorFrame->tree()->parent(); 888 if (ancestorFrame) 889 originDomain = ancestorFrame->document()->domain(); 890 } 891 892 if (targetDomain == originDomain) 893 return true; 894 895 if (!originFrame->settings()->privateBrowsingEnabled()) { 876 if (!targetFrame->settings()->privateBrowsingEnabled()) { 877 // FIXME: this error message should contain more specifics of why the same origin check has failed. 878 String message = String::format("Unsafe JavaScript attempt to access frame with URL %s from frame with URL %s. Domains, protocols and ports must match.\n", 879 targetDocument->URL().utf8().data(), originDocument->URL().utf8().data()); 880 896 881 if (Interpreter::shouldPrintExceptions()) 897 printf("Unsafe JavaScript attempt to access frame with URL %s from frame with URL %s. Domains must match.\n", 898 targetDocument->URL().latin1(), originDocument->URL().latin1()); 899 String message = String::format("Unsafe JavaScript attempt to access frame with URL %s from frame with URL %s. Domains must match.\n", 900 targetDocument->URL().latin1(), originDocument->URL().latin1()); 882 printf("%s", message.utf8().data()); 883 901 884 if (Page* page = targetFrame->page()) 902 885 page->chrome()->addMessageToConsole(JSMessageSource, ErrorMessageLevel, message, 1, String()); // FIXME: provide a real line number and source URL. … … 904 887 905 888 return false; 889 906 890 } 907 891 … … 933 917 } 934 918 935 bool Window::isSafeScript(ExecState *exec) const936 {937 Frame* frame = impl()->frame();938 if (!frame)939 return false;940 Frame* activeFrame = Window::retrieveActive(exec)->impl()->frame();941 if (!activeFrame)942 return false;943 if (activeFrame == frame)944 return true;945 946 WebCore::Document* thisDocument = frame->document();947 948 // JS may be attempting to access the "window" object, which should be valid,949 // even if the document hasn't been constructed yet. If the document doesn't950 // exist yet allow JS to access the window object.951 if (!thisDocument)952 return true;953 954 WebCore::Document* actDocument = activeFrame->document();955 956 const SecurityOrigin& actSecurityOrigin = actDocument->securityOrigin();957 const SecurityOrigin& thisSecurityOrigin = thisDocument->securityOrigin();958 959 if (actSecurityOrigin.canAccess(thisSecurityOrigin))960 return true;961 962 if (!frame->settings()->privateBrowsingEnabled()) {963 // FIXME: this error message should contain more specifics of why the same origin check has failed.964 String message = String::format("Unsafe JavaScript attempt to access frame with URL %s from frame with URL %s. Domains, protocols and ports must match.\n",965 thisDocument->URL().utf8().data(), actDocument->URL().utf8().data());966 967 if (Interpreter::shouldPrintExceptions())968 printf("%s", message.utf8().data());969 970 if (Page* page = frame->page())971 page->chrome()->addMessageToConsole(JSMessageSource, ErrorMessageLevel, message, 1, String());972 }973 974 return false;975 }976 977 919 void Window::setListener(ExecState *exec, const AtomicString &eventType, JSValue *func) 978 920 { 979 if (! isSafeScript(exec))921 if (!allowsAccessFrom(exec)) 980 922 return; 981 923 Frame* frame = impl()->frame(); … … 991 933 JSValue *Window::getListener(ExecState *exec, const AtomicString &eventType) const 992 934 { 993 if (! isSafeScript(exec))935 if (!allowsAccessFrom(exec)) 994 936 return jsUndefined(); 995 937 Frame* frame = impl()->frame(); … … 1363 1305 1364 1306 const Window* window = Window::retrieveWindow(frame); 1365 if (!completedURL.isEmpty() && (!completedURL.startsWith("javascript:", false) || (window && window-> isSafeScript(exec)))) {1307 if (!completedURL.isEmpty() && (!completedURL.startsWith("javascript:", false) || (window && window->allowsAccessFrom(exec)))) { 1366 1308 bool userGesture = activeFrame->scriptProxy()->processingUserGesture(); 1367 1309 frame->loader()->scheduleLocationChange(completedURL, activeFrame->loader()->outgoingReferrer(), false, userGesture); … … 1526 1468 UString s = v->toString(exec); 1527 1469 1528 if (!window-> isSafeScript(exec))1470 if (!window->allowsAccessFrom(exec)) 1529 1471 return jsUndefined(); 1530 1472 if (v->isString()) { … … 1560 1502 JSValue *v = args[0]; 1561 1503 1562 if (!window-> isSafeScript(exec))1504 if (!window->allowsAccessFrom(exec)) 1563 1505 return jsUndefined(); 1564 1506 (const_cast<Window*>(window))->clearTimeout(v->toInt32(exec)); … … 1578 1520 UString s = v->toString(exec); 1579 1521 1580 if (!window-> isSafeScript(exec))1522 if (!window->allowsAccessFrom(exec)) 1581 1523 return jsUndefined(); 1582 1524 if (args.size() >= 2 && v->isString()) { … … 1609 1551 return jsUndefined(); 1610 1552 1611 if (!window-> isSafeScript(exec))1553 if (!window->allowsAccessFrom(exec)) 1612 1554 return jsUndefined(); 1613 1555 if (JSEventListener* listener = window->findOrCreateJSEventListener(args[1])) … … 1626 1568 return jsUndefined(); 1627 1569 1628 if (!window-> isSafeScript(exec))1570 if (!window->allowsAccessFrom(exec)) 1629 1571 return jsUndefined(); 1630 1572 if (JSEventListener* listener = window->findJSEventListener(args[1])) … … 1656 1598 1657 1599 // If anyone implements these, they need the safe script security check. 1658 if (!window-> isSafeScript(exec))1600 if (!window->allowsAccessFrom(exec)) 1659 1601 return jsUndefined(); 1660 1602 // Not implemented. … … 1959 1901 && entry->value.functionValue != &LocationProtoFuncReload::create 1960 1902 && entry->value.functionValue != &LocationProtoFuncAssign::create)) { 1961 if (!window || !window-> isSafeScript(exec)) {1903 if (!window || !window->allowsAccessFrom(exec)) { 1962 1904 slot.setUndefined(this); 1963 1905 return true; … … 1976 1918 KURL url = m_frame->loader()->url(); 1977 1919 const Window* window = Window::retrieveWindow(m_frame); 1978 bool sameDomainAccess = window && window-> isSafeScript(exec);1920 bool sameDomainAccess = window && window->allowsAccessFrom(exec); 1979 1921 1980 1922 const HashEntry *entry = Lookup::findEntry(&LocationTable, p); … … 2059 2001 DeprecatedString str = args[0]->toString(exec); 2060 2002 const Window* window = Window::retrieveWindow(frame); 2061 if (!str.startsWith("javascript:", false) || (window && window-> isSafeScript(exec))) {2003 if (!str.startsWith("javascript:", false) || (window && window->allowsAccessFrom(exec))) { 2062 2004 bool userGesture = p->scriptProxy()->processingUserGesture(); 2063 2005 frame->loader()->scheduleLocationChange(p->loader()->completeURL(str).url(), p->loader()->outgoingReferrer(), true, userGesture); … … 2078 2020 2079 2021 Window* window = Window::retrieveWindow(frame); 2080 if (!window-> isSafeScript(exec))2081 return jsUndefined(); 2082 2083 if (!frame->loader()->url().url().startsWith("javascript:", false) || (window && window-> isSafeScript(exec))) {2022 if (!window->allowsAccessFrom(exec)) 2023 return jsUndefined(); 2024 2025 if (!frame->loader()->url().url().startsWith("javascript:", false) || (window && window->allowsAccessFrom(exec))) { 2084 2026 bool userGesture = Window::retrieveActive(exec)->impl()->frame()->scriptProxy()->processingUserGesture(); 2085 2027 frame->loader()->scheduleRefresh(userGesture); … … 2103 2045 const Window *window = Window::retrieveWindow(frame); 2104 2046 DeprecatedString dstUrl = p->loader()->completeURL(DeprecatedString(args[0]->toString(exec))).url(); 2105 if (!dstUrl.startsWith("javascript:", false) || (window && window-> isSafeScript(exec))) {2047 if (!dstUrl.startsWith("javascript:", false) || (window && window->allowsAccessFrom(exec))) { 2106 2048 bool userGesture = p->scriptProxy()->processingUserGesture(); 2107 2049 // We want a new history item if this JS was called via a user gesture … … 2123 2065 2124 2066 Window* window = Window::retrieveWindow(frame); 2125 if (!window-> isSafeScript(exec))2126 return jsUndefined(); 2127 2128 if (!frame || !Window::retrieveWindow(frame)-> isSafeScript(exec))2067 if (!window->allowsAccessFrom(exec)) 2068 return jsUndefined(); 2069 2070 if (!frame || !Window::retrieveWindow(frame)->allowsAccessFrom(exec)) 2129 2071 return jsString(); 2130 2072 … … 2169 2111 return Window::retrieve(frame); 2170 2112 } 2171 2113 2172 2114 } // namespace WebCore -
trunk/WebCore/bindings/js/kjs_window.h
r28468 r28565 104 104 105 105 void timerFired(DOMWindowTimer*); 106 107 static bool isSafeScript(const JSGlobalObject *origin, const JSGlobalObject *target);108 virtual bool isSafeScript(const JSGlobalObject* other) const { return Window::isSafeScript(this, other); }109 bool isSafeScript(ExecState*) const;110 106 111 107 Location* location() const; … … 141 137 virtual const ClassInfo* classInfo() const { return &info; } 142 138 static const ClassInfo info; 143 139 144 140 virtual ExecState* globalExec(); 141 145 142 virtual bool shouldInterruptScript() const; 143 144 virtual bool allowsAccessFrom(const JSGlobalObject*) const; 145 bool allowsAccessFrom(ExecState* exec) const { return allowsAccessFrom(exec->dynamicGlobalObject()); } 146 146 147 147 enum { -
trunk/WebCore/bindings/objc/WebScriptObject.mm
r28468 r28565 208 208 return false; 209 209 210 return _private->originRootObject->globalObject()->isSafeScript(root->globalObject());210 return root->globalObject()->allowsAccessFrom(_private->originRootObject->globalObject()); 211 211 } 212 212 -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r28468 r28565 922 922 923 923 if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) { 924 push(@implContent, " if (! isSafeScript(exec))\n");924 push(@implContent, " if (!allowsAccessFrom(exec))\n"); 925 925 push(@implContent, " return jsUndefined();\n"); 926 926 } … … 1026 1026 1027 1027 if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) { 1028 push(@implContent, " if (! isSafeScript(exec))\n");1028 push(@implContent, " if (!allowsAccessFrom(exec))\n"); 1029 1029 push(@implContent, " return;\n"); 1030 1030 }
Note: See TracChangeset
for help on using the changeset viewer.