Skip to content

Instantly share code, notes, and snippets.

@amihalik
Last active August 29, 2015 14:23
Show Gist options
  • Save amihalik/6af391b805d7a7e24794 to your computer and use it in GitHub Desktop.
Save amihalik/6af391b805d7a7e24794 to your computer and use it in GitHub Desktop.
<html>
<body>
<h2>Remove Url Defense</h2>
<form method="post" action="fixUrls">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">Enter URL Defended Text here:&nbsp;</td>
</tr>
<tr>
<td><textarea cols="150" rows="20" id="myTextArea"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><input type="button" onclick='callJsApi();' value="Process Text"></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><textarea cols="150" rows="20" id="goodTextArea"></textarea></td>
</tr>
</table>
</form>
<script type="text/javascript">
function callJsApi() {
var ppPattern = /(https:..urldefense\S*)\s/g;
var str = document.getElementById("myTextArea").value;
str.match(ppPattern).forEach(function(proofpointUrl) {
var urlPattern = /u=([^&]*)[&\s]/g;
var encodedUrl = urlPattern.exec(proofpointUrl)[1].replace(/_/g,'/').replace(/-/g,'%');
encodedUrl = decodeURIComponent(encodedUrl);
str = str.replace(proofpointUrl, encodedUrl);
});
document.getElementById("goodTextArea").value = str;
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment