Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfcec4fe

Browse files
author
zhourenjian
committed
Support Browser#setText for different domain scenarios
1 parent7712231 commitfcec4fe

File tree

1 file changed

+23
-6
lines changed
  • sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/browser

1 file changed

+23
-6
lines changed

‎sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/browser/Browser.java‎

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,8 @@ public boolean setText(String html) {
14011401
try {
14021402
var doc = handle.contentWindow.document;
14031403
doc.open ();
1404-
if (O$.isIE) {
1404+
if (O$.isIE && window["xss.domain.enabled"] == true
1405+
&& domain != null && domain.length > 0) {
14051406
doc.domain = domain;
14061407
}
14071408
doc.write (html);
@@ -1420,12 +1421,17 @@ public boolean setText(String html) {
14201421
* @j2sNative
14211422
var handle = arguments[0];
14221423
var html = arguments[1];
1423-
var domain = document.domain;
1424-
if (O$.isIE) {
1424+
var domain = null;
1425+
try {
1426+
domain = document.domain;
1427+
} catch (e) {}
1428+
if (O$.isIE && window["xss.domain.enabled"] == true
1429+
&& domain != null && domain.length > 0) {
14251430
document.domain = domain;
14261431
}
14271432
if (handle.contentWindow != null) {
1428-
if (O$.isIE) {
1433+
if (O$.isIE && window["xss.domain.enabled"] == true
1434+
&& domain != null && domain.length > 0) {
14291435
handle.contentWindow.location = "#"diff-5e6243b82ffcbc9f3d96ce3d0b687512adbf072754a6fd25e0083e29dea8d619-1430-1436-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">1430
1436
} else {
14311437
handle.contentWindow.location = "about:blank";
@@ -1436,13 +1442,24 @@ public boolean setText(String html) {
14361442
try {
14371443
var doc = handle.contentWindow.document;
14381444
doc.open ();
1439-
if (O$.isIE) {
1445+
if (O$.isIE && window["xss.domain.enabled"] == true
1446+
&& domain != null && domain.length > 0) {
14401447
doc.domain = domain;
14411448
}
14421449
doc.write (html);
14431450
doc.close ();
14441451
} catch (e) {
1445-
window.setTimeout (this.generateLazyIframeWriting (handle, domain, html), 25);
1452+
if (O$.isIE && (domain == null || domain.length == 0)
1453+
&& e.message != null && e.message.indexOf ("Access is denied") != -1) {
1454+
var jsHTML = html.replaceAll("\\\\", "\\\\\\\\")
1455+
.replaceAll("\r", "\\\\r")
1456+
.replaceAll("\n", "\\\\n")
1457+
.replaceAll("\"", "\\\\\"");
1458+
handle.src = "#"diff-5e6243b82ffcbc9f3d96ce3d0b687512adbf072754a6fd25e0083e29dea8d619-1445-1459-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">
1459+
// In IE 8.0, it is still failing ...
1460+
} else {
1461+
window.setTimeout (this.generateLazyIframeWriting (handle, domain, html), 25);
1462+
}
14461463
}
14471464
*/
14481465
privatenativevoidiframeDocumentWrite(Objecthandle,Stringhtml);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp