-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'susimail-html' into 'master'
Susimail: Add support for HTML email See merge request i2p-hackers/i2p.i2p!177
- Loading branch information
Showing
7 changed files
with
328 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* @license http://www.gnu.org/licenses/gpl-2.0.html GPL-2.0 */ | ||
/* see also licenses/LICENSE-GPLv2.txt */ | ||
|
||
// called from iframed.js | ||
|
||
function setupFrame() { | ||
var frames = document.getElementsByClassName("iframedsusi"); | ||
for(index = 0; index < frames.length; index++) | ||
{ | ||
var frame = frames[index]; | ||
frame.addEventListener("load", function() { | ||
// old way, iframed.js. we use this as a backup in case | ||
// the js injection didn't work | ||
|
||
resizeFrame(frame); | ||
|
||
// new way, iframe-resizer | ||
|
||
// By default the height of the iFrame is calculated by converting the margin of the body to px and then adding the top and bottom figures to the offsetHeight of the body tag. | ||
// In cases where CSS styles causes the content to flow outside the body you may need to change this setting to one of the following options. | ||
// If the default option doesn't work then the best solutions is to use either taggedElement, or lowestElement. | ||
// The **lowestElement** option is the most reliable way of determining the page height. | ||
// However, it does have a performance impact, as it requires checking the position of every element on the page. | ||
iFrameResize({ log: false, heightCalculationMethod: 'lowestElement' }, frame) | ||
}, true); | ||
} | ||
} | ||
|
||
/* @license-end */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package i2p.susi.webmail; | ||
|
||
import java.util.Locale; | ||
|
||
/** | ||
* Check user-agent for support of CSP | ||
* @since 0.9.62 | ||
*/ | ||
class CSPDetector { | ||
/** | ||
* ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy | ||
*/ | ||
public static boolean supportsCSP(String ua) { | ||
if (ua == null) | ||
return false; | ||
ua = ua.toLowerCase(Locale.US); | ||
// mobile anything: assume no | ||
if (ua.contains("mobile")) | ||
return false; | ||
|
||
// ref: https://www.useragents.me/ | ||
// min versions | ||
// chrome: 25 | ||
// covers edge, opera | ||
int idx = ua.indexOf("chrome/"); | ||
if (idx >= 0) { | ||
idx += 7; | ||
return getVersion(ua, idx) >= 25; | ||
} | ||
// safari: 7 | ||
idx = ua.indexOf("safari/"); | ||
if (idx >= 0) { | ||
idx = ua.indexOf("version/"); | ||
if (idx >= 0) { | ||
idx += 8; | ||
return getVersion(ua, idx) >= 7; | ||
} | ||
} | ||
// firefox: 23 | ||
idx = ua.indexOf("firefox/"); | ||
if (idx >= 0) { | ||
idx += 8; | ||
return getVersion(ua, idx) >= 23; | ||
} | ||
return false; | ||
} | ||
|
||
private static int getVersion(String ua, int idx) { | ||
int rv = 0; | ||
for (int i = idx; i < ua.length(); i++) { | ||
char c = ua.charAt(i); | ||
if (c < '0' || c > '9') | ||
break; | ||
if (i > idx) | ||
rv *= 10; | ||
rv += c - '0'; | ||
} | ||
//System.out.println("Found version " + rv + " in " + ua); | ||
return rv; | ||
} | ||
|
||
/**** | ||
public static void main(String[] args) { | ||
String s = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0"; | ||
System.out.println(supportsCSP(s) + " " + s); | ||
s = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"; | ||
System.out.println(supportsCSP(s) + " " + s); | ||
s = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.1"; | ||
System.out.println(supportsCSP(s) + " " + s); | ||
s = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0"; | ||
System.out.println(supportsCSP(s) + " " + s); | ||
s = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/11.0"; | ||
System.out.println(supportsCSP(s) + " " + s); | ||
s = "xxx"; | ||
System.out.println(supportsCSP(s) + " " + s); | ||
} | ||
****/ | ||
} |
Oops, something went wrong.