Skip to content

Instantly share code, notes, and snippets.

@atuttle
Created July 24, 2013 13:49
Show Gist options
  • Save atuttle/6070762 to your computer and use it in GitHub Desktop.
Save atuttle/6070762 to your computer and use it in GitHub Desktop.
<cfscript>
original = fileRead(expandPath("./src.html"), "UTF-8");
encoded = encodeForHTML(original);
function htmlDecode(HTML){
return replaceList(arguments.HTML, "&lt;,&gt;,&amp;,&quot;", '<,>,&,"');
}
decoded = htmlDecode(encoded);
compared = compare(original,decoded);
if (compared != 0){
loopTo = min(len(original), len(decoded));
for (i=1; i <= loopTo; i++){
cOriginal = mid(original, i, 1);
cDecoded = mid(decoded, i, 1);
match = cOriginal == cDecoded;
writeOutput("#cOriginal#:#cDecoded# : (#asc(cOriginal)#:#asc(cDecoded)#): #match#<br>");
if (!match){
loopTo = min(i+10, loopTo); // stop soon, but continue for a bit to give some context
}
}
writeOutput('------------<br>');
loopTo = len(encoded);
for (i=1; i <= loopTo; i++){
char = mid(encoded, i, 1);
code = asc(char);
writeOutput("#char#:#code#<br>");
if (code == 10){
loopTo = i + 5;
}
}
}
</cfscript>
<:< : (60:60): YES
!:& : (33:38): NO
d:# : (100:35): NO
o:x : (111:120): NO
c:2 : (99:50): NO
t:1 : (116:49): NO
y:; : (121:59): NO
p:d : (112:100): NO
e:o : (101:111): NO
:c : (32:99): NO
h:t : (104:116): NO
t:y : (116:121): NO
------------
&:38
l:108
t:116
;:59
&:38
#:35
x:120
2:50
1:49
;:59
d:100
o:111
c:99
t:116
y:121
p:112
e:101
:32
h:104
t:116
m:109
l:108
&:38
g:103
t:116
;:59
&:38
#:35
x:120
a:97
;:59
&:38
l:108
t:116
;:59
h:104
t:116
m:109
l:108
:32
l:108
a:97
n:110
g:103
&:38
#:35
x:120
3:51
d:100
;:59
&:38
q:113
u:117
o:111
t:116
;:59
e:101
n:110
&:38
q:113
u:117
o:111
t:116
;:59
&:38
g:103
t:116
;:59
&:38
#:35
x:120
a:97
;:59
:32
:32
:32
:32
&:38
l:108
t:116
;:59
h:104
e:101
a:97
d:100
&:38
g:103
t:116
;:59
&:38
#:35
x:120
a:97
;:59
:32
:32
:32
:32
:32
:32
:32
:32
&:38
l:108
t:116
;:59
m:109
e:101
t:116
a:97
:32
c:99
h:104
a:97
r:114
s:115
e:101
t:116
&:38
#:35
x:120
3:51
d:100
;:59
&:38
q:113
u:117
o:111
t:116
;:59
u:117
t:116
f:102
-:45
8:56
&:38
q:113
u:117
o:111
t:116
;:59
&:38
g:103
t:116
;:59
&:38
#:35
x:120
a:97
;:59
:32
:32
:32
:32
:32
:32
:32
:32
&:38
l:108
t:116
;:59
t:116
i:105
t:116
l:108
e:101
&:38
g:103
t:116
;:59
T:84
h:104
i:105
s:115
:32
&:38
a:97
m:109
p:112
;:59
:32
t:116
h:104
a:97
t:116
&:38
l:108
t:116
;:59
&:38
#:35
x:120
2:50
f:102
;:59
t:116
i:105
t:116
l:108
e:101
&:38
g:103
t:116
;:59
&:38
#:35
x:120
a:97
;:59
:32
:32
:32
:32
&:38
l:108
t:116
;:59
&:38
#:35
x:120
2:50
f:102
;:59
h:104
e:101
a:97
d:100
&:38
g:103
t:116
;:59
&:38
#:35
x:120
a:97
;:59
:32
:32
:32
:32
&:38
l:108
t:116
;:59
b:98
o:111
d:100
y:121
&:38
g:103
t:116
;:59
&:38
#:35
x:120
a:97
;:59
:32
:32
:32
:32
:32
:32
:32
:32
&:38
l:108
t:116
;:59
h:104
1:49
&:38
g:103
t:116
;:59
T:84
h:104
e:101
:32
h:104
e:101
a:97
d:100
i:105
n:110
g:103
&:38
l:108
t:116
;:59
&:38
#:35
x:120
2:50
f:102
;:59
h:104
1:49
&:38
g:103
t:116
;:59
&:38
#:35
x:120
a:97
;:59
:32
:32
:32
:32
:32
:32
:32
:32
&:38
l:108
t:116
;:59
p:112
&:38
g:103
t:116
;:59
T:84
h:104
e:101
:32
c:99
o:111
n:110
t:116
e:101
n:110
t:116
&:38
l:108
t:116
;:59
&:38
#:35
x:120
2:50
f:102
;:59
p:112
&:38
g:103
t:116
;:59
&:38
#:35
x:120
a:97
;:59
:32
:32
:32
:32
&:38
l:108
t:116
;:59
&:38
#:35
x:120
2:50
f:102
;:59
b:98
o:111
d:100
y:121
&:38
g:103
t:116
;:59
&:38
#:35
x:120
a:97
;:59
&:38
l:108
t:116
;:59
&:38
#:35
x:120
2:50
f:102
;:59
h:104
t:116
m:109
l:108
&:38
g:103
t:116
;:59
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>This & that</title>
</head>
<body>
<h1>The heading</h1>
<p>The content</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment