forked from Botanical/BotanJS
Escape strings
This commit is contained in:
parent
49d9bb0f4f
commit
cbd36260dc
@ -20,6 +20,7 @@
|
|||||||
var XDate = __import( "Astro.utils.Date" );
|
var XDate = __import( "Astro.utils.Date" );
|
||||||
|
|
||||||
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
|
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
|
||||||
|
var unescapeStr = ns[ NS_INVOKE ]( "unescapeStr" );
|
||||||
var compileProp = ns[ NS_INVOKE ]( "compileProp" );
|
var compileProp = ns[ NS_INVOKE ]( "compileProp" );
|
||||||
|
|
||||||
var postData = __import( "System.Net.postData" );
|
var postData = __import( "System.Net.postData" );
|
||||||
@ -72,8 +73,8 @@
|
|||||||
|
|
||||||
if( override )
|
if( override )
|
||||||
{
|
{
|
||||||
id = override.value;
|
id = unescapeStr( override.value );
|
||||||
title = override.title || "";
|
title = unescapeStr( override.title ) || "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -160,7 +161,7 @@
|
|||||||
|
|
||||||
if( opt = stage.getDAttribute( "title" ) )
|
if( opt = stage.getDAttribute( "title" ) )
|
||||||
{
|
{
|
||||||
options += " title=\"" + opt + "\"";
|
options += " title=\"" + escapeStr( opt ) + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "[articlelink" + options + "]"
|
return "[articlelink" + options + "]"
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
var MessageBox = __import( "Components.MessageBox" );
|
var MessageBox = __import( "Components.MessageBox" );
|
||||||
|
|
||||||
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
|
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
|
||||||
|
var unescapeStr = ns[ NS_INVOKE ]( "unescapeStr" );
|
||||||
var compileProp = ns[ NS_INVOKE ]( "compileProp" );
|
var compileProp = ns[ NS_INVOKE ]( "compileProp" );
|
||||||
|
|
||||||
var code = function ( insertSnippet, snippetWrap, createContext, override )
|
var code = function ( insertSnippet, snippetWrap, createContext, override )
|
||||||
@ -99,15 +100,15 @@
|
|||||||
).show();
|
).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
, visualizer = function ( submitted, override )
|
, visualizer = function( submitted, override )
|
||||||
{
|
{
|
||||||
var lang, code, inline
|
var lang, code, inline
|
||||||
, stage = this.stage;
|
, stage = this.stage;
|
||||||
|
|
||||||
if ( override )
|
if( override )
|
||||||
{
|
{
|
||||||
lang = override.lang;
|
lang = unescapeStr( override.lang );
|
||||||
code = override.value;
|
code = unescapeStr( override.value );
|
||||||
inline = override.inline;
|
inline = override.inline;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
/** @type {Components.MessageBox} */
|
/** @type {Components.MessageBox} */
|
||||||
var MessageBox = __import( "Components.MessageBox" );
|
var MessageBox = __import( "Components.MessageBox" );
|
||||||
|
|
||||||
|
var unescapeStr = ns[ NS_INVOKE ]( "unescapeStr" );
|
||||||
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
|
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
|
||||||
|
|
||||||
var footnote = function (insertSnippet, snippetWrap, createContext, override)
|
var footnote = function( insertSnippet, snippetWrap, createContext, override )
|
||||||
{
|
{
|
||||||
var temp, i, j
|
var temp, i, j
|
||||||
|
|
||||||
@ -38,12 +39,12 @@
|
|||||||
).show();
|
).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
, visualizer = function (submitted, override)
|
, visualizer = function( submitted, override )
|
||||||
{
|
{
|
||||||
|
|
||||||
var mText, stage = this.stage;
|
var mText, stage = this.stage;
|
||||||
|
|
||||||
mText = override ? override.value : this.mText.value;
|
mText = override ? unescapeStr( override.value ) : this.mText.value;
|
||||||
|
|
||||||
if (submitted && mText)
|
if (submitted && mText)
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
/** @type {Components.MessageBox} */
|
/** @type {Components.MessageBox} */
|
||||||
var MessageBox = __import( "Components.MessageBox" );
|
var MessageBox = __import( "Components.MessageBox" );
|
||||||
|
|
||||||
|
var unescapeStr = ns[ NS_INVOKE ]( "unescapeStr" );
|
||||||
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
|
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
|
||||||
var compileProp = ns[ NS_INVOKE ]( "compileProp" );
|
var compileProp = ns[ NS_INVOKE ]( "compileProp" );
|
||||||
|
|
||||||
@ -94,8 +95,8 @@
|
|||||||
|
|
||||||
if ( override )
|
if ( override )
|
||||||
{
|
{
|
||||||
size = override.size;
|
size = unescapeStr( override.size );
|
||||||
heading = override.value;
|
heading = unescapeStr( override.value );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -14,8 +14,9 @@
|
|||||||
var MessageBox = __import( "Components.MessageBox" );
|
var MessageBox = __import( "Components.MessageBox" );
|
||||||
|
|
||||||
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
|
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
|
||||||
|
var unescapeStr = ns[ NS_INVOKE ]( "unescapeStr" );
|
||||||
|
|
||||||
var html = function (insertSnippet, snippetWrap, createContext, override)
|
var html = function( insertSnippet, snippetWrap, createContext, override )
|
||||||
{
|
{
|
||||||
var temp, i, j
|
var temp, i, j
|
||||||
|
|
||||||
@ -38,12 +39,12 @@
|
|||||||
).show();
|
).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
, visualizer = function (submitted, override)
|
, visualizer = function( submitted, override )
|
||||||
{
|
{
|
||||||
|
|
||||||
var code, stage = this.stage;
|
var code, stage = this.stage;
|
||||||
|
|
||||||
code = override ? override.value : this.code.value;
|
code = override ? unescapeStr( override.value ) : this.code.value;
|
||||||
|
|
||||||
if (submitted && code)
|
if (submitted && code)
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
/** @type {Components.MessageBox} */
|
/** @type {Components.MessageBox} */
|
||||||
var MessageBox = __import( "Components.MessageBox" );
|
var MessageBox = __import( "Components.MessageBox" );
|
||||||
|
|
||||||
|
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
|
||||||
|
var unescapeStr = ns[ NS_INVOKE ]( "unescapeStr" );
|
||||||
var compileProp = ns[ NS_INVOKE ]( "compileProp" );
|
var compileProp = ns[ NS_INVOKE ]( "compileProp" );
|
||||||
|
|
||||||
var image = function( insertSnippet, snippetWrap, createContext, override )
|
var image = function( insertSnippet, snippetWrap, createContext, override )
|
||||||
@ -61,8 +63,8 @@
|
|||||||
|
|
||||||
if ( override )
|
if ( override )
|
||||||
{
|
{
|
||||||
src = override.value;
|
src = unescapeStr( override.value );
|
||||||
href = override.href;
|
href = unescapeStr( override.href );
|
||||||
preferred = override.preferred ? "on" : "";
|
preferred = override.preferred ? "on" : "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -155,10 +157,9 @@
|
|||||||
var element = IDOMElement( stage )
|
var element = IDOMElement( stage )
|
||||||
, props = [ "href", "preferred" ]
|
, props = [ "href", "preferred" ]
|
||||||
|
|
||||||
return "[img"
|
return "[img" + compileProp( element, props ) + "]"
|
||||||
+ compileProp( element, props )
|
+ escapeStr( element.getDAttribute( "value" ) )
|
||||||
+ "]"
|
+ "[/img]"
|
||||||
+ element.getDAttribute( "value" ) + "[/img]"
|
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,7 +12,10 @@
|
|||||||
var Dand = __import( "Dandelion" );
|
var Dand = __import( "Dandelion" );
|
||||||
/** @type {Components.MessageBox} */
|
/** @type {Components.MessageBox} */
|
||||||
var MessageBox = __import( "Components.MessageBox" );
|
var MessageBox = __import( "Components.MessageBox" );
|
||||||
|
|
||||||
|
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
|
||||||
|
var unescapeStr = ns[ NS_INVOKE ]( "unescapeStr" );
|
||||||
|
|
||||||
var link = function(insertSnippet, snippetWrap, createContext, override)
|
var link = function(insertSnippet, snippetWrap, createContext, override)
|
||||||
{
|
{
|
||||||
var temp, i, j
|
var temp, i, j
|
||||||
@ -46,10 +49,10 @@
|
|||||||
var src, href
|
var src, href
|
||||||
, stage = this.stage;
|
, stage = this.stage;
|
||||||
|
|
||||||
if (override)
|
if( override )
|
||||||
{
|
{
|
||||||
src = override.value;
|
src = unescapeStr( override.value );
|
||||||
href = override.href;
|
href = unescapeStr( override.href );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -117,12 +120,12 @@
|
|||||||
{
|
{
|
||||||
// [link href=\"" + this.href.value + "\"]" + text + "[/link]
|
// [link href=\"" + this.href.value + "\"]" + text + "[/link]
|
||||||
var element = IDOMElement(stage)
|
var element = IDOMElement(stage)
|
||||||
, href = element.getDAttribute("href");
|
, href = escapeStr( element.getDAttribute("href") )
|
||||||
|
, val = escapeStr( element.getDAttribute("value") ) ;
|
||||||
|
|
||||||
return "[link" + (href ? (" href=\"" + href + "\"") : "") + "]" + element.getDAttribute("value") + "[/link]";
|
return "[link" + (href ? (" href=\"" + href + "\"") : "") + "]" + val + "[/link]";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
__static_method( link, "compile", compile );
|
__static_method( link, "compile", compile );
|
||||||
|
|
||||||
ns[ NS_EXPORT ]( EX_CLASS, "Link", link );
|
ns[ NS_EXPORT ]( EX_CLASS, "Link", link );
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
var MessageBox = __import( "Components.MessageBox" );
|
var MessageBox = __import( "Components.MessageBox" );
|
||||||
|
|
||||||
var compileProp = ns[ NS_INVOKE ]( "compileProp" );
|
var compileProp = ns[ NS_INVOKE ]( "compileProp" );
|
||||||
|
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
|
||||||
|
var unescapeStr = ns[ NS_INVOKE ]( "unescapeStr" );
|
||||||
|
|
||||||
var spoiler = function(insertSnippet, snippetWrap, createContext, override)
|
var spoiler = function(insertSnippet, snippetWrap, createContext, override)
|
||||||
{
|
{
|
||||||
@ -48,15 +50,15 @@
|
|||||||
, "OK", "Cancel", visualizer.bind({title: input_title, content:v_snippetInput, expanded: input_expanded, stage: this._stage})).show();
|
, "OK", "Cancel", visualizer.bind({title: input_title, content:v_snippetInput, expanded: input_expanded, stage: this._stage})).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
, visualizer = function (submitted, override)
|
, visualizer = function( submitted, override )
|
||||||
{
|
{
|
||||||
var content, title, expanded
|
var content, title, expanded
|
||||||
, stage = this.stage;
|
, stage = this.stage;
|
||||||
|
|
||||||
if (override)
|
if( override )
|
||||||
{
|
{
|
||||||
content = override.value;
|
content = unescapeStr( override.value );
|
||||||
title = override.title;
|
title = unescapeStr( override.title );
|
||||||
expanded = override.expanded ? "on" : "";
|
expanded = override.expanded ? "on" : "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -142,7 +144,7 @@
|
|||||||
return "[spoiler"
|
return "[spoiler"
|
||||||
+ compileProp( element, props )
|
+ compileProp( element, props )
|
||||||
+ "]"
|
+ "]"
|
||||||
+ element.getDAttribute( "value" )
|
+ escapeStr( element.getDAttribute( "value" ) )
|
||||||
+ "[/spoiler]";
|
+ "[/spoiler]";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,7 +4,22 @@
|
|||||||
|
|
||||||
var escapeStr = function ( str )
|
var escapeStr = function ( str )
|
||||||
{
|
{
|
||||||
return str.replace( /\[/g, "[" ).replace( /\]/g, "]" );
|
if( !str ) return str;
|
||||||
|
return str
|
||||||
|
.replace( /\[/g, "[" )
|
||||||
|
.replace( /\]/g, "]" )
|
||||||
|
.replace( /"/g, """ )
|
||||||
|
;
|
||||||
|
};
|
||||||
|
|
||||||
|
var unescapeStr = function( str )
|
||||||
|
{
|
||||||
|
if( !str ) return str;
|
||||||
|
return str
|
||||||
|
.replace( /[/g, "[" )
|
||||||
|
.replace( /]/g, "]" )
|
||||||
|
.replace( /"/g, "\"" )
|
||||||
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
var compileProp = function ( _iDOM, keys )
|
var compileProp = function ( _iDOM, keys )
|
||||||
@ -14,12 +29,13 @@
|
|||||||
{
|
{
|
||||||
if( ( k = _iDOM.getDAttribute(keys[i]) ) )
|
if( ( k = _iDOM.getDAttribute(keys[i]) ) )
|
||||||
{
|
{
|
||||||
j += " " + keys[i] + "=\"" + k + "\"";
|
j += " " + keys[i] + "=\"" + escapeStr( k ) + "\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return j;
|
return j;
|
||||||
};
|
};
|
||||||
|
|
||||||
ns[ NS_EXPORT ]( EX_FUNC, "escapeStr", escapeStr );
|
ns[ NS_EXPORT ]( EX_FUNC, "escapeStr", escapeStr );
|
||||||
|
ns[ NS_EXPORT ]( EX_FUNC, "unescapeStr", unescapeStr );
|
||||||
ns[ NS_EXPORT ]( EX_FUNC, "compileProp", compileProp );
|
ns[ NS_EXPORT ]( EX_FUNC, "compileProp", compileProp );
|
||||||
})();
|
})();
|
||||||
|
@ -3,4 +3,6 @@ Astro.Blog.AstroEdit.Visualizer.Snippet = function(){};
|
|||||||
/** @type {Function} */
|
/** @type {Function} */
|
||||||
Astro.Blog.AstroEdit.Visualizer.Snippet.escapeStr;
|
Astro.Blog.AstroEdit.Visualizer.Snippet.escapeStr;
|
||||||
/** @type {Function} */
|
/** @type {Function} */
|
||||||
|
Astro.Blog.AstroEdit.Visualizer.Snippet.unescapeStr;
|
||||||
|
/** @type {Function} */
|
||||||
Astro.Blog.AstroEdit.Visualizer.Snippet.compileProp;
|
Astro.Blog.AstroEdit.Visualizer.Snippet.compileProp;
|
||||||
|
Loading…
Reference in New Issue
Block a user