Skip to content

Commit 3d2ee77

Browse files
committed
SyntaxHighlighter v3.0.9 that addresses some security issues. Props Ben Bidner.
1 parent 38285d1 commit 3d2ee77

28 files changed

+569
-234
lines changed

syntaxhighlighter3/scripts/shAutoloader.js

Lines changed: 125 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,133 @@
66
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
77
*
88
* @version
9-
* 3.0.83 (July 02 2010)
10-
*
9+
* 3.0.83 (Wed, 16 Apr 2014 03:56:09 GMT)
10+
*
1111
* @copyright
12-
* Copyright (C) 2004-2010 Alex Gorbatchev.
12+
* Copyright (C) 2004-2013 Alex Gorbatchev.
1313
*
1414
* @license
1515
* Dual licensed under the MIT and GPL licenses.
1616
*/
17-
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(2(){1 h=5;h.I=2(){2 n(c,a){4(1 d=0;d<c.9;d++)i[c[d]]=a}2 o(c){1 a=r.H("J"),d=3;a.K=c;a.M="L/t";a.G="t";a.u=a.v=2(){6(!d&&(!8.7||8.7=="F"||8.7=="z")){d=q;e[c]=q;a:{4(1 p y e)6(e[p]==3)B a;j&&5.C(k)}a.u=a.v=x;a.D.O(a)}};r.N.R(a)}1 f=Q,l=h.P(),i={},e={},j=3,k=x,b;5.T=2(c){k=c;j=q};4(b=0;b<f.9;b++){1 m=f[b].w?f[b]:f[b].S(/\\s+/),g=m.w();n(m,g)}4(b=0;b<l.9;b++)6(g=i[l[b].E.A]){e[g]=3;o(g)}}})();',56,56,'|var|function|false|for|SyntaxHighlighter|if|readyState|this|length|||||||||||||||||true|document||javascript|onload|onreadystatechange|pop|null|in|complete|brush|break|highlight|parentNode|params|loaded|language|createElement|autoloader|script|src|text|type|body|removeChild|findElements|arguments|appendChild|split|all'.split('|'),0,{}))
17+
(function() {
18+
19+
var sh = SyntaxHighlighter;
20+
21+
/**
22+
* Provides functionality to dynamically load only the brushes that a needed to render the current page.
23+
*
24+
* There are two syntaxes that autoload understands. For example:
25+
*
26+
* SyntaxHighlighter.autoloader(
27+
* [ 'applescript', 'Scripts/shBrushAppleScript.js' ],
28+
* [ 'actionscript3', 'as3', 'Scripts/shBrushAS3.js' ]
29+
* );
30+
*
31+
* or a more easily comprehendable one:
32+
*
33+
* SyntaxHighlighter.autoloader(
34+
* 'applescript Scripts/shBrushAppleScript.js',
35+
* 'actionscript3 as3 Scripts/shBrushAS3.js'
36+
* );
37+
*/
38+
sh.autoloader = function()
39+
{
40+
var list = arguments,
41+
elements = sh.findElements(),
42+
brushes = {},
43+
scripts = {},
44+
all = SyntaxHighlighter.all,
45+
allCalled = false,
46+
allParams = null,
47+
i
48+
;
49+
50+
SyntaxHighlighter.all = function(params)
51+
{
52+
allParams = params;
53+
allCalled = true;
54+
};
55+
56+
function addBrush(aliases, url)
57+
{
58+
for (var i = 0; i < aliases.length; i++)
59+
brushes[aliases[i]] = url;
60+
};
61+
62+
function getAliases(item)
63+
{
64+
return item.pop
65+
? item
66+
: item.split(/\s+/)
67+
;
68+
}
69+
70+
// create table of aliases and script urls
71+
for (i = 0; i < list.length; i++)
72+
{
73+
var aliases = getAliases(list[i]),
74+
url = aliases.pop()
75+
;
76+
77+
addBrush(aliases, url);
78+
}
79+
80+
// dynamically add <script /> tags to the document body
81+
for (i = 0; i < elements.length; i++)
82+
{
83+
var url = brushes[elements[i].params.brush];
84+
85+
if(url && scripts[url] === undefined)
86+
{
87+
if(elements[i].params['html-script'] === 'true')
88+
{
89+
if(scripts[brushes['xml']] === undefined) {
90+
loadScript(brushes['xml']);
91+
scripts[url] = false;
92+
}
93+
}
94+
95+
scripts[url] = false;
96+
loadScript(url);
97+
}
98+
}
99+
100+
function loadScript(url)
101+
{
102+
var script = document.createElement('script'),
103+
done = false
104+
;
105+
106+
script.src = url;
107+
script.type = 'text/javascript';
108+
script.language = 'javascript';
109+
script.onload = script.onreadystatechange = function()
110+
{
111+
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete'))
112+
{
113+
done = true;
114+
scripts[url] = true;
115+
checkAll();
116+
117+
// Handle memory leak in IE
118+
script.onload = script.onreadystatechange = null;
119+
script.parentNode.removeChild(script);
120+
}
121+
};
122+
123+
// sync way of adding script tags to the page
124+
document.body.appendChild(script);
125+
};
126+
127+
function checkAll()
128+
{
129+
for(var url in scripts)
130+
if (scripts[url] == false)
131+
return;
132+
133+
if (allCalled)
134+
SyntaxHighlighter.highlight(allParams);
135+
};
136+
};
137+
138+
})();

syntaxhighlighter3/scripts/shBrushAS3.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
77
*
88
* @version
9-
* 3.0.83 (July 02 2010)
10-
*
9+
* 3.0.83 (Wed, 16 Apr 2014 03:56:09 GMT)
10+
*
1111
* @copyright
12-
* Copyright (C) 2004-2010 Alex Gorbatchev.
12+
* Copyright (C) 2004-2013 Alex Gorbatchev.
1313
*
1414
* @license
1515
* Dual licensed under the MIT and GPL licenses.
1616
*/
1717
;(function()
1818
{
1919
// CommonJS
20-
typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null;
20+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
2121

2222
function Brush()
2323
{

syntaxhighlighter3/scripts/shBrushAppleScript.js

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@
66
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
77
*
88
* @version
9-
* 3.0.83 (July 02 2010)
10-
*
9+
* 3.0.83 (Wed, 16 Apr 2014 03:56:09 GMT)
10+
*
1111
* @copyright
12-
* Copyright (C) 2004-2010 Alex Gorbatchev.
12+
* Copyright (C) 2004-2013 Alex Gorbatchev.
1313
*
1414
* @license
1515
* Dual licensed under the MIT and GPL licenses.
1616
*/
1717
;(function()
1818
{
1919
// CommonJS
20-
typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null;
20+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
2121

2222
function Brush()
2323
{
2424
// AppleScript brush by David Chambers
2525
// http://davidchambersdesign.com/
2626
var keywords = 'after before beginning continue copy each end every from return get global in local named of set some that the then times to where whose with without';
2727
var ordinals = 'first second third fourth fifth sixth seventh eighth ninth tenth last front back middle';
28-
var specials = 'activate add alias AppleScript ask attachment boolean class constant delete duplicate empty exists false id integer list make message modal modified new no paragraph pi properties quit real record remove rest result reveal reverse run running save string true word yes';
28+
var specials = 'activate add alias ask attachment boolean class constant delete duplicate empty exists id integer list make message modal modified new no pi properties quit real record remove rest result reveal reverse run running save string word yes';
2929

3030
this.regexList = [
3131

@@ -38,7 +38,7 @@
3838
{ regex: /"[\s\S]*?"/gm,
3939
css: 'string' },
4040

41-
{ regex: /(?:,|:|¬|'s\b|\(|\)|\{|\}|«|\b\w*»)/g,
41+
{ regex: /(?:,|:|¬|'s\b|\(|\)|\{|\}|«|\b\w*»)/g, // operators
4242
css: 'color1' },
4343

4444
{ regex: /(-)?(\d)+(\.(\d)?)?(E\+(\d)+)?/g, // numbers
@@ -56,8 +56,33 @@
5656
{ regex: /\b(?:about|above|against|around|at|below|beneath|beside|between|by|(apart|aside) from|(instead|out) of|into|on(to)?|over|since|thr(ough|u)|under)\b/g,
5757
css: 'color3' },
5858

59-
{ regex: /\b(?:adding folder items to|after receiving|choose( ((remote )?application|color|folder|from list|URL))?|clipboard info|set the clipboard to|(the )?clipboard|entire contents|display(ing| (alert|dialog|mode))?|document( (edited|file|nib name))?|file( (name|type))?|(info )?for|giving up after|(name )?extension|quoted form|return(ed)?|second(?! item)(s)?|list (disks|folder)|text item(s| delimiters)?|(Unicode )?text|(disk )?item(s)?|((current|list) )?view|((container|key) )?window|with (data|icon( (caution|note|stop))?|parameter(s)?|prompt|properties|seed|title)|case|diacriticals|hyphens|numeric strings|punctuation|white space|folder creation|application(s( folder)?| (processes|scripts position|support))?|((desktop )?(pictures )?|(documents|downloads|favorites|home|keychain|library|movies|music|public|scripts|sites|system|users|utilities|workflows) )folder|desktop|Folder Action scripts|font(s| panel)?|help|internet plugins|modem scripts|(system )?preferences|printer descriptions|scripting (additions|components)|shared (documents|libraries)|startup (disk|items)|temporary items|trash|on server|in AppleTalk zone|((as|long|short) )?user name|user (ID|locale)|(with )?password|in (bundle( with identifier)?|directory)|(close|open for) access|read|write( permission)?|(g|s)et eof|using( delimiters)?|starting at|default (answer|button|color|country code|entr(y|ies)|identifiers|items|name|location|script editor)|hidden( answer)?|open(ed| (location|untitled))?|error (handling|reporting)|(do( shell)?|load|run|store) script|administrator privileges|altering line endings|get volume settings|(alert|boot|input|mount|output|set) volume|output muted|(fax|random )?number|round(ing)?|up|down|toward zero|to nearest|as taught in school|system (attribute|info)|((AppleScript( Studio)?|system) )?version|(home )?directory|(IPv4|primary Ethernet) address|CPU (type|speed)|physical memory|time (stamp|to GMT)|replacing|ASCII (character|number)|localized string|from table|offset|summarize|beep|delay|say|(empty|multiple) selections allowed|(of|preferred) type|invisibles|showing( package contents)?|editable URL|(File|FTP|News|Media|Web) [Ss]ervers|Telnet hosts|Directory services|Remote applications|waiting until completion|saving( (in|to))?|path (for|to( (((current|frontmost) )?application|resource))?)|POSIX (file|path)|(background|RGB) color|(OK|cancel) button name|cancel button|button(s)?|cubic ((centi)?met(re|er)s|yards|feet|inches)|square ((kilo)?met(re|er)s|miles|yards|feet)|(centi|kilo)?met(re|er)s|miles|yards|feet|inches|lit(re|er)s|gallons|quarts|(kilo)?grams|ounces|pounds|degrees (Celsius|Fahrenheit|Kelvin)|print( (dialog|settings))?|clos(e(able)?|ing)|(de)?miniaturized|miniaturizable|zoom(ed|able)|attribute run|action (method|property|title)|phone|email|((start|end)ing|home) page|((birth|creation|current|custom|modification) )?date|((((phonetic )?(first|last|middle))|computer|host|maiden|related) |nick)?name|aim|icq|jabber|msn|yahoo|address(es)?|save addressbook|should enable action|city|country( code)?|formatte(r|d address)|(palette )?label|state|street|zip|AIM [Hh]andle(s)?|my card|select(ion| all)?|unsaved|(alpha )?value|entr(y|ies)|group|(ICQ|Jabber|MSN) handle|person|people|company|department|icon image|job title|note|organization|suffix|vcard|url|copies|collating|pages (across|down)|request print time|target( printer)?|((GUI Scripting|Script menu) )?enabled|show Computer scripts|(de)?activated|awake from nib|became (key|main)|call method|of (class|object)|center|clicked toolbar item|closed|for document|exposed|(can )?hide|idle|keyboard (down|up)|event( (number|type))?|launch(ed)?|load (image|movie|nib|sound)|owner|log|mouse (down|dragged|entered|exited|moved|up)|move|column|localization|resource|script|register|drag (info|types)|resigned (active|key|main)|resiz(e(d)?|able)|right mouse (down|dragged|up)|scroll wheel|(at )?index|should (close|open( untitled)?|quit( after last window closed)?|zoom)|((proposed|screen) )?bounds|show(n)?|behind|in front of|size (mode|to fit)|update(d| toolbar item)?|was (hidden|miniaturized)|will (become active|close|finish launching|hide|miniaturize|move|open|quit|(resign )?active|((maximum|minimum|proposed) )?size|show|zoom)|bundle|data source|movie|pasteboard|sound|tool(bar| tip)|(color|open|save) panel|coordinate system|frontmost|main( (bundle|menu|window))?|((services|(excluded from )?windows) )?menu|((executable|frameworks|resource|scripts|shared (frameworks|support)) )?path|(selected item )?identifier|data|content(s| view)?|character(s)?|click count|(command|control|option|shift) key down|context|delta (x|y|z)|key( code)?|location|pressure|unmodified characters|types|(first )?responder|playing|(allowed|selectable) identifiers|allows customization|(auto saves )?configuration|visible|image( name)?|menu form representation|tag|user(-| )defaults|associated file name|(auto|needs) display|current field editor|floating|has (resize indicator|shadow)|hides when deactivated|level|minimized (image|title)|opaque|position|release when closed|sheet|title(d)?)\b/g,
60-
css: 'color3' },
59+
{ regex: /\b(?:adding folder items to|after receiving|clipboard info|set the clipboard to|(the )?clipboard|entire contents|document( (edited|file|nib name))?|file( (name|type))?|(info )?for|giving up after|(name )?extension|return(ed)?|second(?! item)(s)?|list (disks|folder)|(Unicode )?text|(disk )?item(s)?|((current|list) )?view|((container|key) )?window|case|diacriticals|hyphens|numeric strings|punctuation|white space|folder creation|application(s( folder)?| (processes|scripts position|support))?|((desktop )?(pictures )?|(documents|downloads|favorites|home|keychain|library|movies|music|public|scripts|sites|system|users|utilities|workflows) )folder|desktop|Folder Action scripts|font(s| panel)?|help|internet plugins|modem scripts|(system )?preferences|printer descriptions|scripting (additions|components)|shared (documents|libraries)|startup (disk|items)|temporary items|trash|on server|in AppleTalk zone|((as|long|short) )?user name|user (ID|locale)|(with )?password|in (bundle( with identifier)?|directory)|(close|open for) access|read|write( permission)?|(g|s)et eof|starting at|hidden( answer)?|open(ed| (location|untitled))?|error (handling|reporting)|administrator privileges|altering line endings|get volume settings|(alert|boot|input|mount|output|set) volume|output muted|(fax|random )?number|round(ing)?|up|down|toward zero|to nearest|as taught in school|system (attribute|info)|((AppleScript( Studio)?|system) )?version|(home )?directory|(IPv4|primary Ethernet) address|CPU (type|speed)|physical memory|time (stamp|to GMT)|replacing|ASCII (character|number)|localized string|from table|offset|summarize|beep|delay|say|(empty|multiple) selections allowed|(of|preferred) type|invisibles|showing( package contents)?|editable URL|(File|FTP|News|Media|Web) [Ss]ervers|Telnet hosts|Directory services|Remote applications|waiting until completion|saving( (in|to))?|path (for|to( (((current|frontmost) )?application|resource))?)|(background|RGB) color|(OK|cancel) button name|cancel button|button(s)?|cubic ((centi)?met(re|er)s|yards|feet|inches)|square ((kilo)?met(re|er)s|miles|yards|feet)|(centi|kilo)?met(re|er)s|miles|yards|feet|inches|lit(re|er)s|gallons|quarts|(kilo)?grams|ounces|pounds|degrees (Celsius|Fahrenheit|Kelvin)|print( (dialog|settings))?|clos(e(able)?|ing)|(de)?miniaturized|miniaturizable|zoom(ed|able)|attribute run|action (method|property|title)|phone|email|((start|end)ing|home) page|((birth|creation|current|custom|modification) )?date|((((phonetic )?(first|last|middle))|computer|host|maiden|related) |nick)?name|aim|icq|jabber|msn|yahoo|address(es)?|save addressbook|should enable action|city|country( code)?|formatte(r|d address)|(palette )?label|state|street|zip|AIM [Hh]andle(s)?|my card|select(ion| all)?|unsaved|(alpha )?value|entr(y|ies)|(ICQ|Jabber|MSN) handle|person|people|company|department|icon image|job title|note|organization|suffix|vcard|url|copies|collating|pages (across|down)|request print time|target( printer)?|((GUI Scripting|Script menu) )?enabled|show Computer scripts|(de)?activated|awake from nib|became (key|main)|call method|of (class|object)|center|clicked toolbar item|closed|for document|exposed|(can )?hide|idle|keyboard (down|up)|event( (number|type))?|launch(ed)?|load (image|movie|nib|sound)|owner|log|mouse (down|dragged|entered|exited|moved|up)|move|column|localization|resource|script|register|drag (info|types)|resigned (active|key|main)|resiz(e(d)?|able)|right mouse (down|dragged|up)|scroll wheel|(at )?index|should (close|open( untitled)?|quit( after last window closed)?|zoom)|((proposed|screen) )?bounds|show(n)?|behind|in front of|size (mode|to fit)|update(d| toolbar item)?|was (hidden|miniaturized)|will (become active|close|finish launching|hide|miniaturize|move|open|quit|(resign )?active|((maximum|minimum|proposed) )?size|show|zoom)|bundle|data source|movie|pasteboard|sound|tool(bar| tip)|(color|open|save) panel|coordinate system|frontmost|main( (bundle|menu|window))?|((services|(excluded from )?windows) )?menu|((executable|frameworks|resource|scripts|shared (frameworks|support)) )?path|(selected item )?identifier|data|content(s| view)?|character(s)?|click count|(command|control|option|shift) key down|context|delta (x|y|z)|key( code)?|location|pressure|unmodified characters|types|(first )?responder|playing|(allowed|selectable) identifiers|allows customization|(auto saves )?configuration|visible|image( name)?|menu form representation|tag|user(-| )defaults|associated file name|(auto|needs) display|current field editor|floating|has (resize indicator|shadow)|hides when deactivated|level|minimized (image|title)|opaque|position|release when closed|sheet|title(d)?)\b/g,
60+
css: 'color4' },
61+
62+
{ regex: /\b(?:tracks|paragraph|text item(s)?)\b/g,
63+
css: 'classes' },
64+
65+
{ regex: /\b(?:AppleScript|album|video kind|grouping|length|text item delimiters|quoted form|POSIX path(?= of))\b/g,
66+
css: 'properties' },
67+
68+
{ regex: /\b(?:run|exists|count)\b/g,
69+
css: 'commandNames' },
70+
71+
{ regex: /\b(?:POSIX (file|path))\b/g,
72+
css: 'additionClasses' },
73+
74+
{ regex: /\b(?:message|with (data|icon( (caution|note|stop))?|parameter(s)?|prompt|properties|seed|title)|regexp|string result|using( delimiters)?|default (answer|button|color|country code|entr(y|ies)|identifiers|items|name|location|script editor))\b/g,
75+
css: 'additionParameterNames' },
76+
77+
{ regex: /\b(?:display(ing| (alert|dialog|mode))?|choose( ((remote )?application|color|folder|from list|URL))?|(do( shell)?|load|run|store) script|re_compile|find text)\b/g,
78+
css: 'additionCommandNames' },
79+
80+
{ regex: /\b(?:xxx)\b/g,
81+
css: 'parameterNames' },
82+
83+
{ regex: /\b(?:true|false|none)\b/g,
84+
css: 'enumeratedValues' },
85+
6186

6287
{ regex: new RegExp(this.getKeywords(specials), 'gm'), css: 'color3' },
6388
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' },
@@ -72,4 +97,4 @@
7297

7398
// CommonJS
7499
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
75-
})();
100+
})();

0 commit comments

Comments
 (0)