From f06aa8058b7e32ba32d4551074b6e0b8a300f751 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Mon, 21 Oct 2013 15:02:40 -0400
Subject: [PATCH] Bump version after security fix

---
 program/js/tiny_mce/plugins/table/js/table.js |   77 ++++++++++++++++++++++++++++++++------
 1 files changed, 64 insertions(+), 13 deletions(-)

diff --git a/program/js/tiny_mce/plugins/table/js/table.js b/program/js/tiny_mce/plugins/table/js/table.js
index 520d857..1db243b 100644
--- a/program/js/tiny_mce/plugins/table/js/table.js
+++ b/program/js/tiny_mce/plugins/table/js/table.js
@@ -60,7 +60,19 @@
 	if (action == "update") {
 		dom.setAttrib(elm, 'cellPadding', cellpadding, true);
 		dom.setAttrib(elm, 'cellSpacing', cellspacing, true);
-		dom.setAttrib(elm, 'border', border);
+
+		if (!isCssSize(border)) {
+			dom.setAttrib(elm, 'border', border);
+		} else {
+			dom.setAttrib(elm, 'border', '');
+		}
+
+		if (border == '') {
+			dom.setStyle(elm, 'border-width', '');
+			dom.setStyle(elm, 'border', '');
+			dom.setAttrib(elm, 'border', '');
+		}
+
 		dom.setAttrib(elm, 'align', align);
 		dom.setAttrib(elm, 'frame', frame);
 		dom.setAttrib(elm, 'rules', rules);
@@ -119,7 +131,7 @@
 		if (bordercolor != "") {
 			elm.style.borderColor = bordercolor;
 			elm.style.borderStyle = elm.style.borderStyle == "" ? "solid" : elm.style.borderStyle;
-			elm.style.borderWidth = border == "" ? "1px" : border;
+			elm.style.borderWidth = cssSize(border);
 		} else
 			elm.style.borderColor = '';
 
@@ -132,7 +144,7 @@
 		//elm.outerHTML = elm.outerHTML;
 
 		inst.nodeChanged();
-		inst.execCommand('mceEndUndoLevel');
+		inst.execCommand('mceEndUndoLevel', false, {}, {skip_undo: true});
 
 		// Repaint if dimensions changed
 		if (formObj.width.value != orgTableWidth || formObj.height.value != orgTableHeight)
@@ -146,7 +158,10 @@
 	html += '<table';
 
 	html += makeAttrib('id', id);
-	html += makeAttrib('border', border);
+	if (!isCssSize(border)) {
+		html += makeAttrib('border', border);
+	}
+
 	html += makeAttrib('cellpadding', cellpadding);
 	html += makeAttrib('cellspacing', cellspacing);
 	html += makeAttrib('data-mce-new', '1');
@@ -227,13 +242,20 @@
 	} else
 		inst.execCommand('mceInsertContent', false, html);
 
-	tinymce.each(dom.select('table[data-mce-new]'), function(node) {
-		var td = dom.select('td', node);
+	tinymce.each(dom.select('table[data-mce-new]'), function(node) {
+		var tdorth = dom.select('td,th', node);
+
+		// Fixes a bug in IE where the caret cannot be placed after the table if the table is at the end of the document
+		if (tinymce.isIE && node.nextSibling == null) {
+			if (inst.settings.forced_root_block)
+				dom.insertAfter(dom.create(inst.settings.forced_root_block), node);
+			else
+				dom.insertAfter(dom.create('br', {'data-mce-bogus': '1'}), node);
+		}
 
 		try {
-			// IE9 might fail to do this selection
-			inst.selection.select(td[0], true);
-			inst.selection.collapse();
+			// IE9 might fail to do this selection 
+			inst.selection.setCursorLocation(tdorth[0], 0);
 		} catch (ex) {
 			// Ignore
 		}
@@ -242,7 +264,7 @@
 	});
 
 	inst.addVisual();
-	inst.execCommand('mceEndUndoLevel');
+	inst.execCommand('mceEndUndoLevel', false, {}, {skip_undo: true});
 
 	tinyMCEPopup.close();
 }
@@ -284,6 +306,15 @@
 	var inst = tinyMCEPopup.editor, dom = inst.dom;
 	var formObj = document.forms[0];
 	var elm = dom.getParent(inst.selection.getNode(), "table");
+
+	// Hide advanced fields that isn't available in the schema
+	tinymce.each("summary id rules dir style frame".split(" "), function(name) {
+		var tr = tinyMCEPopup.dom.getParent(name, "tr") || tinyMCEPopup.dom.getParent("t" + name, "tr");
+
+		if (tr && !tinyMCEPopup.editor.schema.isValid("table", name)) {
+			tr.style.display = 'none';
+		}
+	});
 
 	action = tinyMCEPopup.getWindowArg('action');
 
@@ -384,6 +415,20 @@
 	formObj.style.value = dom.serializeStyle(st);
 }
 
+function isCssSize(value) {
+	return /^[0-9.]+(%|in|cm|mm|em|ex|pt|pc|px)$/.test(value);
+}
+
+function cssSize(value, def) {
+	value = tinymce.trim(value || def);
+
+	if (!isCssSize(value)) {
+		return parseInt(value, 10) + 'px';
+	}
+
+	return value;
+}
+
 function changedBackgroundImage() {
 	var formObj = document.forms[0];
 	var st = dom.parseStyle(formObj.style.value);
@@ -398,8 +443,14 @@
 	var st = dom.parseStyle(formObj.style.value);
 
 	// Update border width if the element has a color
-	if (formObj.border.value != "" && formObj.bordercolor.value != "")
-		st['border-width'] = formObj.border.value + "px";
+	if (formObj.border.value != "" && (isCssSize(formObj.border.value) || formObj.bordercolor.value != ""))
+		st['border-width'] = cssSize(formObj.border.value);
+	else {
+		if (!formObj.border.value) {
+			st['border'] = '';
+			st['border-width'] = '';
+		}
+	}
 
 	formObj.style.value = dom.serializeStyle(st);
 }
@@ -415,7 +466,7 @@
 
 		// Add border-width if it's missing
 		if (!st['border-width'])
-			st['border-width'] = formObj.border.value == "" ? "1px" : formObj.border.value + "px";
+			st['border-width'] = cssSize(formObj.border.value, 1);
 	}
 
 	formObj.style.value = dom.serializeStyle(st);

--
Gitblit v1.9.1