Index: /CKEditor/tests/dt/core/htmlparser/filter.html
===================================================================
--- /CKEditor/tests/dt/core/htmlparser/filter.html	(revision 5477)
+++ /CKEditor/tests/dt/core/htmlparser/filter.html	(revision 5477)
@@ -0,0 +1,94 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>CKEDITOR.htmlParser.filter</title>
+	<meta name="tags" content="editor,unit,stable">
+	<script type="text/javascript" src="../../../cktester/cell.js"></script>
+	<script type="text/javascript">
+	//<![CDATA[
+CKEDITOR.test.runner.defer = true;
+CKEDITOR.plugins.load( 'htmlwriter' , function()
+{
+ CKEDITOR.test.runner.run();
+} );
+
+var tc;
+CKEDITOR.test.addTestCase( tc = ( function()
+{
+	// Local reference to the "assert" object.
+	var assert = CKEDITOR.test.assert;
+
+	/**
+	 * Wrapper of the combination of htmlParser with htmlWriter, for convenience of
+	 * testing, formatting of writer has been disabled.
+	 */
+	function htmlParse( htmlString, filter )
+	{
+		var writer = new CKEDITOR.htmlParser.basicWriter(),
+				fragment = CKEDITOR.htmlParser.fragment.fromHtml( htmlString );
+		fragment.writeHtml( writer, filter );
+		return writer.getHtml();
+	}
+
+	return {
+
+		// Test applying filter rules of duplicate name.
+		test_filter_rules_same_name : function()
+		{
+			var filter = new CKEDITOR.htmlParser.filter();
+			filter.addRules( {
+				elements : {
+					div : function( element )
+					{
+						assert.areSame( CKEDITOR.NODE_ELEMENT, element.type );
+						assert.areSame( 'div', element.name );
+						element.name = 'span';
+						return element;
+					}
+				},
+				attributes : {
+					'class' : function( attrValue )
+					{
+						assert.areSame( 'class1', attrValue );
+						return 'class2';
+					}
+				},
+				text : function( value )
+				{
+					assert.areSame( 'some text', value );
+					return 'some other text';
+				}
+			} );
+
+			filter.addRules( {
+				elements :
+				{
+					div : function( element )
+					{
+						assert.fail( 'This filter should not be applied.');
+					}
+				},
+				attributes : {
+					'class' : function( attrValue )
+					{
+						assert.areSame( 'class2', attrValue );
+						return attrValue;
+					}
+				},
+				text : function( text )
+				{
+					assert.areSame( 'some other text', text );
+					return text;
+				}
+			} );
+			assert.areSame( '<span class="class2">some other text</span>', htmlParse( '<div class="class1">some text</div>', filter ) );
+		},
+
+		name : document.title
+	};
+} )() );
+	//]]>
+	</script>
+</head>
+<body>
+</html>
Index: Editor/tests/tt/5617/1.html
===================================================================
--- /CKEditor/tests/tt/5617/1.html	(revision 5476)
+++ 	(revision )
@@ -1,94 +1,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-	<title>Test Ticket #5617</title>
-	<meta name="tags" content="editor,unit,all">
-	<script type="text/javascript" src="../../cktester/cell.js"></script>
-	<script type="text/javascript">
-	//<![CDATA[
-CKEDITOR.test.runner.defer = true;
-CKEDITOR.plugins.load( 'htmlwriter' , function()
-{
- CKEDITOR.test.runner.run();
-} );
-
-var tc;
-CKEDITOR.test.addTestCase( tc = ( function()
-{
-	// Local reference to the "assert" object.
-	var assert = CKEDITOR.test.assert;
-
-	/**
-	 * Wrapper of the combination of htmlParser with htmlWriter, for convenience of
-	 * testing, formatting of writer has been disabled.
-	 */
-	function htmlParse( htmlString, filter )
-	{
-		var writer = new CKEDITOR.htmlParser.basicWriter(),
-				fragment = CKEDITOR.htmlParser.fragment.fromHtml( htmlString );
-		fragment.writeHtml( writer, filter );
-		return writer.getHtml();
-	}
-
-	return {
-
-		// Test applying filter rules of duplicate name.
-		test_filter_rules_same_name : function()
-		{
-			var filter = new CKEDITOR.htmlParser.filter();
-			filter.addRules( {
-				elements : {
-					div : function( element )
-					{
-						assert.areSame( CKEDITOR.NODE_ELEMENT, element.type );
-						assert.areSame( 'div', element.name );
-						element.name = 'span';
-						return element;
-					}
-				},
-				attributes : {
-					'class' : function( attrValue )
-					{
-						assert.areSame( 'class1', attrValue );
-						return 'class2';
-					}
-				},
-				text : function( value )
-				{
-					assert.areSame( 'some text', value );
-					return 'some other text';
-				}
-			} );
-
-			filter.addRules( {
-				elements :
-				{
-					div : function( element )
-					{
-						assert.fail( 'This filter should not be applied.');
-					}
-				},
-				attributes : {
-					'class' : function( attrValue )
-					{
-						assert.areSame( 'class2', attrValue );
-						return attrValue;
-					}
-				},
-				text : function( text )
-				{
-					assert.areSame( 'some other text', text );
-					return text;
-				}
-			} );
-			assert.areSame( '<span class="class2">some other text</span>', htmlParse( '<div class="class1">some text</div>', filter ) );
-		},
-
-		name : document.title
-	};
-} )() );
-	//]]>
-	</script>
-</head>
-<body>
-</html>
Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 5476)
+++ /CKEditor/trunk/CHANGES.html	(revision 5477)
@@ -82,4 +82,5 @@
 		<li><a href="http://dev.fckeditor.net/ticket/5586">#5586</a> : [Firefox] Maximize the second editor ruins fullscreen mode.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/5671">#5671</a> : SCAYT bookstrap script could be added multiple times unnecessarily.</li>
+		<li><a href="http://dev.fckeditor.net/ticket/5617">#5617</a> : Html filter system does not allow two 'text' filter rules.</li>
 		<li>Updated the following language files:<ul>
 			<li><a href="http://dev.fckeditor.net/ticket/5432">#5432</a> : Dutch;</li>
Index: /CKEditor/trunk/_source/core/htmlparser/filter.js
===================================================================
--- /CKEditor/trunk/_source/core/htmlparser/filter.js	(revision 5476)
+++ /CKEditor/trunk/_source/core/htmlparser/filter.js	(revision 5477)
@@ -228,24 +228,50 @@
 	}
 
+	// Invoke filters sequentially on the array, break the iteration
+	// when it doesn't make sense to continue anymore.
 	function callItems( currentEntry )
 	{
-		var isObject = ( typeof currentEntry == 'object' );
+		var isNode = currentEntry.type
+			|| currentEntry instanceof CKEDITOR.htmlParser.fragment;
 
 		for ( var i = 0 ; i < this.length ; i++ )
 		{
+			// Backup the node info before filtering.
+			if ( isNode )
+			{
+				var orgType = currentEntry.type,
+						orgName = currentEntry.name;
+			}
+
 			var item = this[ i ],
 				ret = item.apply( window, arguments );
 
-			if ( typeof ret != 'undefined' )
-			{
-				if ( ret === false )
-					return false;
-
-				if ( isObject && ret != currentEntry )
+			if ( ret === false )
+				return ret;
+
+			// We're filtering node (element/fragment).
+			if ( isNode )
+			{
+				// No further filtering if it's not anymore 
+				// fitable for the subsequent filters.
+				if ( ret && ( ret.name != orgName
+					|| ret.type != orgType ) )
+				{
 					return ret;
-			}
-		}
-
-		return null;
+				}
+			}
+			// Filtering value (nodeName/textValue/attrValue).
+			else
+			{
+				// No further filtering if it's not
+				// any more values.
+				if ( typeof ret != 'string' )
+					return ret;
+			}
+
+			ret != undefined && ( currentEntry = ret );
+		}
+
+		return currentEntry;
 	}
 })();
