Skip to content

Commit

Permalink
#7894: enhanced handling of nested links.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.ckeditor.com/CKEditor/trunk@7223 da63caf2-3823-0410-a1e8-d69ccee00dfb
  • Loading branch information
garry.yao committed Aug 24, 2011
1 parent dae27e3 commit 47c9db2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ <h3>
<li><a href="http://dev.ckeditor.com/ticket/7490">#7490</a> : [IE] Block format leaks to the next unselected line when <code>enterMode</code> is set to <code>BR</code>.</li>
<li><a href="http://dev.ckeditor.com/ticket/8087">#8087</a> : Indenting list items may add redundant text direction attributes.</li>
<li><a href="http://dev.ckeditor.com/ticket/6200">#6200</a> : Styling for certain dialog element type that miss focus outline like checkbox.</li>
<li><a href="http://dev.ckeditor.com/ticket/7894">#7894</a> : Fault tolerance when parsing malformed link.</li>
<li>Updated the following language files:<ul>
<li><a href="http://dev.ckeditor.com/ticket/8128">#8128</a> : Italian;</li>
<li><a href="http://dev.ckeditor.com/ticket/8126">#8126</a>, <a href="http://dev.ckeditor.com/ticket/8256">#8256</a> : Norwegian (Bokmål and Nynorsk);</li>
Expand Down
12 changes: 11 additions & 1 deletion _source/core/htmlparser/fragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ CKEDITOR.htmlParser.fragment = function() {
// Dtd of the fragment element, basically it accept anything except for intermediate structure, e.g. orphan <li>.
var rootDtd = CKEDITOR.tools.extend( {}, { html:1 }, CKEDITOR.dtd.html, CKEDITOR.dtd.body, CKEDITOR.dtd.head, { style:1,script:1 } );

function isRemoveEmpty( node ) {
// Empty link is to be removed when empty but not anchor. (#7894)
return node.name == 'a' && node.attributes.href || CKEDITOR.dtd.$removeEmpty[ node.name ];
}

/**
* Creates a {@link CKEDITOR.htmlParser.fragment} from an HTML string.
* @param {String} fragmentHtml The HTML to be parsed, filling the fragment.
Expand Down Expand Up @@ -94,6 +99,11 @@ CKEDITOR.htmlParser.fragment = function() {
// to properly process the next entry).
pendingInline.splice( i, 1 );
i--;
} else {
// Some element of the same type cannot be nested, flat them,
// e.g. <a href="#">foo<a href="#">bar</a></a>. (#7894)
if ( pendingName == currentNode.name )
addElement( currentNode, currentNode.parent, 1 ), i--;
}
}
}
Expand Down Expand Up @@ -179,7 +189,7 @@ CKEDITOR.htmlParser.fragment = function() {
element.isOptionalClose = tagName in optionalCloseTags || optionalClose;

// This is a tag to be removed if empty, so do not add it immediately.
if ( CKEDITOR.dtd.$removeEmpty[ tagName ] ) {
if ( isRemoveEmpty( element ) ) {
pendingInline.push( element );
return;
} else if ( tagName == 'pre' )
Expand Down

0 comments on commit 47c9db2

Please sign in to comment.