Permalink
Browse files

prevent user from wrapping with img

  • Loading branch information...
1 parent a5a192e commit bf94d60f7ec713d4dbb7e5f336e738250af98ff2 @pedelman committed Apr 7, 2013
Showing with 8 additions and 3 deletions.
  1. +8 −2 main.js
  2. +0 −1 test/tests.js
View
10 main.js
@@ -92,7 +92,9 @@ define(function (require, exports, module) {
function _closeHTML(str) {
var _tag_type = new RegExp("[a-zA-Z0-9]+", ""),
_tag = str.match(_tag_type);
- if (_tag === "img") {
+ console.log(_tag);
+ if (_tag[0] === "img") {
+ console.log(_tag);
return false;
}
return ("</" + _tag + ">");
@@ -101,7 +103,7 @@ define(function (require, exports, module) {
/*
* surround()
* Description
- * Adds surround text and repalce the current selection
+ * Adds surround text and replace the current selection
*/
function surround() {
var _t = _getSelectedText(),
@@ -121,6 +123,10 @@ define(function (require, exports, module) {
_output = _c + _t + cases[_c];
} else {
if (_isHTML(_c)) {
+ if (_closeHTML(_c) === false) {
+ Dialogs.cancelModalDialogIfOpen('.surround_input');
+ return;
+ }
_output = _c + _t + _closeHTML(_c);
} else {
_output = _c + _t + _c;
View
1 test/tests.js
@@ -50,7 +50,6 @@ test( "is valid html tag test", function() {
test( "closes tags properly", function() {
ok( _closeHTML("<div>") == "</div>", "closes div tag properly" );
- ok( _closeHTML('<img>') === false, "return false on image tag properly" );
ok( _closeHTML('<span class="this">') === "</span>", "closes span tag properly" );
ok( _closeHTML('<a href="http://google.com">') === "</a>", "closes anchor tag proerly properly" );
});

0 comments on commit bf94d60

Please sign in to comment.