Skip to content

Commit

Permalink
Merge branch 't/11536' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
mlewand committed Feb 10, 2014
2 parents 5875583 + fc6c798 commit da5e23c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -5,6 +5,7 @@ CKEditor 4 Changelog

New Features:

* [#11536](http://dev.ckeditor.com/ticket/11536): Added CKEDITOR.tools.htmlDecode method.
* [#11377](http://dev.ckeditor.com/ticket/11377): Unify internal representation of empty anchors using fake objects.
* [#11225](http://dev.ckeditor.com/ticket/11225): Introduced the [`CKEDITOR.tools.transparentImageData`](http://localhost/cksource/ckeditor-docs/build/#!/api/CKEDITOR.tools-property-transparentImageData) property which contains transparent image data to be used in CSS or as images' source.

Expand Down
17 changes: 14 additions & 3 deletions core/tools.js
Expand Up @@ -325,11 +325,22 @@
return String( text ).replace( /&/g, '&amp;' ).replace( />/g, '&gt;' ).replace( /</g, '&lt;' );
},

/**
* Decodes HTML entities.
*
* alert( CKEDITOR.tools.htmlDecode( '&lt;a &amp; b &gt;' ) ); // '<a & b >'
*
* @param {String} The string to be decoded.
* @returns {String} The decoded string.
*/
htmlDecode: function( text ) {
return text.replace( /&amp;/g, '&' ).replace( /&gt;/g, '>' ).replace( /&lt;/g, '<' );
},

/**
* Replaces special HTML characters in HTMLElement attribute with their relative HTML entity values.
*
* element.setAttribute( 'title', '<a " b >' );
* alert( CKEDITOR.tools.htmlEncodeAttr( element.getAttribute( 'title' ) ); // '&gt;a &quot; b &lt;'
* alert( CKEDITOR.tools.htmlEncodeAttr( '<a " b >' ) ); // '&lt;a &quot; b &gt;'
*
* @param {String} The attribute value to be encoded.
* @returns {String} The encoded value.
Expand All @@ -343,7 +354,7 @@
* {@link #htmlEncodeAttr htmlEncodeAttr} back to their plain character
* representation.
*
* alert( CKEDITOR.tools.htmlDecodeAttr( '&gt;a &quot; b &lt;' ); // '<a " b >'
* alert( CKEDITOR.tools.htmlDecodeAttr( '&lt;a &quot; b&gt;' ) ); // '<a " b>'
*
* @param {String} text The text to be decoded.
* @returns {String} The decoded text.
Expand Down

0 comments on commit da5e23c

Please sign in to comment.