GithubHelp home page GithubHelp logo

jquery-clean's People

Contributors

melnikaite avatar mrantix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jquery-clean's Issues

Specifying allowEmpty is Inconvenient for Multiple Tags

What steps will reproduce the problem?

1. Take some arbitrary HTML
2. Use HTML Clean to format it with the option "allowEmpty: true"

What is the expected output? What do you see instead?

Expected: I would expect to see my HTML formatted, with none of it removed

Actual: All of the empty tags will be removed

Now, this could be solved by using "allowEmpty: arrayWithEveryHtmlTag" ... but 
that's an awfully hacky solution.

What version of the product are you using? On what operating system?
1.4.0, Chrome, Linux

Please provide any additional information below.

In general when people want to format their HTML, I think they want to ... 
well, format it, NOT delete arbitrary chunks of it.  This might just be me, but 
I suspect it's actually a very common, if not the most common use, case.  
Therefore, I think:

A) every allowed* option (allowedTags, allowedAttributes, allowedClasses, etc.) 
should take a "true" option (which would indicate "don't delete anything")
B) all of those options should default to true

Just one user's opinion ...


Original issue reported on code.google.com by [email protected] on 16 Jan 2014 at 6:40

how make attributes value allow line break like allow \r\n?

before

 <button type="button" class="btn" data-select="click" data-event="click" data-click="var ht=true;
var s=false;" id="nButton"><i class="doone-icon-doone"></i><span>按钮</span>

after

<button type="button" class="btn" data-select="click" data-event="click" data-click="var" id="nButton">
	<em class="doone-icon-doone"></em> <span>按 钮</span>
</button>

data-click="var" not my want i want all contains line breaks like \r\n , how to config it?

Not Expected output

What steps will reproduce the problem?
1.Entered html <img style = "width:500;hieght:400;"  src = 
"../../parse_file/imgs/safari.jpg">
2. js : $.htmlClean(data,{format:true},allowedAttributes:[["style"],["src"]])

What is the expected output? What do you see instead?
Expected op:
<img style = "width:500;hieght:400;"  src = "../../parse_file/imgs/safari.jpg">

Got op:
<img alt='' />

What version of the product are you using? On what operating system?
1.3

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 11 Jul 2013 at 5:09

Impossible To Format Classes

What steps will reproduce the problem?
1. var html = '<div class="foo">bar</div>';
2. var options = {allowedAttributes: [['class']], allowedClasses: ["foo"], 
format: true};
3. $.htmlClean(html, options)

What is the expected output? What do you see instead?
Expected:
<div class="foo">
    bar
</div>
Actual:
<div>
    bar
</div>

With either the allowedAttributes or allowedClasses option (and especially with 
both) I would expect to see classes in my output.  I'm not certain of that 
though, as the documentation provides no explanation of how those options 
interact.

What version of the product are you using? On what operating system?
version 1.3.0
$Revision: 67 $

Linux

Original issue reported on code.google.com by [email protected] on 6 Feb 2013 at 1:24

Allow empty tags

What steps will reproduce the problem?
1.used this AS input
<div class="test"  style="width:500px; height:400px"><div title=tabOne 
></div><div title=TabTwo ></div><div title=TbT ></div></div>

What is the expected output? What do you see instead?
Expected :
<div class="test" style="width:500px; height:400px">
    <div title=tabOne>
    </div>
    <div title=TabTwo>
    </div>
    <div title=TbT>
    </div>
</div>

Actual:
<div class="easyui-tabs">
</div>

Please provide any additional information below.

which parameters to be passed for htmlClean so that it allows empty tags also?

Original issue reported on code.google.com by [email protected] on 11 Jul 2013 at 11:14

Not Expected output

What steps will reproduce the problem?
1. Used demo site http://www.antix.co.uk/Content/Demos/jQuery-htmlClean/Test.htm
2.Entered code :
<select name="dept" style="width:200px;" multiple ><option value="aa" 
>aitem1</option><option value="bb" selected=1>bitem2</option><option value="cc" 
>bitem3</option><option   >ditem4</option><option   >eitem5</option></select>
3.checked format

What is the expected output? What do you see instead?
Expected:
<select name="dept" style="width:200px;" multiple>
    <option value="aa">aitem1</option>
    <option value="bb" selected=1>bitem2</option>
    <option value="cc">bitem3</option>
    <option>ditem4</option>
    <option>eitem5</option>
</select>

Got op:
<select name="dept">aitem1bitem2bitem3ditem4eitem5</select>

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 11 Jul 2013 at 5:15

ignoreTag option?

What steps will reproduce the problem?
1. Ran the plugin with "format:true'

What is the expected output? 
I was hoping it would clean up the html

What do you see instead?
It removed valid tags i.e. it changes 
<select>option>a</option><option>b</option></select> into <select>a b</select>

What version of the product are you using? On what operating system?
Centos Hosting


Please provide any additional information below.
First this plugin was a great help. What I didn't see was an 'ignoreTag' 
option. You have a 'white list' but to put all the tags I'd only want to keep 
would make for a very large list. I ended up making an 'ignoreTag' option which 
was then added to the tagProtect array. This way it ran and ignored the tags 
that I didn't want touched.

Original issue reported on code.google.com by [email protected] on 24 Feb 2013 at 2:10

  • Merged into: #23

Changes - tagIgnore

Hi,

its working fine, is it possible to make by default all tags in "tagIgnore"
allow selected tags ?

Thanks
KS

Original issue reported on code.google.com by [email protected] on 3 Apr 2010 at 9:33

different disallowed-to-nest tags can't occur one inside another

What steps will reproduce the problem?

  1. use this html: 
    <table><tr><td><h2>hi</h2></td></tr></table>
  2. config with:
    {allowedTags: ["h2"]}
  3. call: 
    $.cleanHtml(data, config)

What is the expected output? 
  <h2>hi</h2>

What do you see instead?
  hi

What version of the product are you using? On what operating system?
  version 1.4.0
  $Revision: 99 $

Please provide any additional information below.

line 144 of unminified code lack checks: && (tag.name == container.tag.name):

144:                     } else if (container.tag.disallowNest && 
tag.disallowNest

Original issue reported on code.google.com by [email protected] on 6 Jan 2015 at 9:34

Does not clean MS Word dirt

MS Word (Mac) code won't be cleaned:

<!-- /* Font Definitions */ @font-face {font-family:"MS 明朝"; panose-1:0 
0 0 0 0 0 0 0 0 0; mso-font-alt:"Optima ExtraBlack"; mso-font-charset:128; 
mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:fixed; 
mso-font-signature:1 134676480 16 0 131072 0;} @font-face {font-family:"MS 
明朝"; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-alt:"Optima ExtraBlack"; 
mso-font-charset:128; mso-generic-font-family:roman; mso-font-format:other; 
mso-font-pitch:fixed; mso-font-signature:1 134676480 16 0 131072 0;} @font-face 
{font-family:Cambria; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-alt:"Times New 
Roman"; mso-font-charset:0; mso-generic-font-family:roman; 
mso-font-format:other; mso-font-pitch:auto; mso-font-signature:0 0 0 0 0 0;} /* 
Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal 
{mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; 
margin-top:0cm; margin-right:0cm; margin-bottom:10.0pt; margin-left:0cm; 
mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Cambria","serif"; 
mso-ascii-font-family:Cambria; mso-ascii-theme-font:minor-latin; 
mso-fareast-font-family:"MS 明朝"; mso-fareast-theme-font:minor-fareast; 
mso-hansi-font-family:Cambria; mso-hansi-theme-font:minor-latin; 
mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} 
.MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; 
font-family:"Cambria","serif"; mso-ascii-font-family:Cambria; 
mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"MS 明朝"; 
mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Cambria; 
mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; 
mso-bidi-theme-font:minor-bidi;} .MsoPapDefault {mso-style-type:export-only; 
margin-bottom:10.0pt;} @page WordSection1 {size:595.0pt 842.0pt; margin:72.0pt 
90.0pt 72.0pt 90.0pt; mso-header-margin:35.4pt; mso-footer-margin:35.4pt; 
mso-paper-source:0;} div.WordSection1 {page:WordSection1;} --> Test

Original issue reported on code.google.com by [email protected] on 9 Sep 2011 at 3:19

Strips out iframes

Whenever it comes across an iframe it gets rid of it regardless of the options 
that I put in

Original issue reported on code.google.com by [email protected] on 13 Jan 2015 at 2:07

Any block level elements are always stripped from inside an inline element.

What steps will reproduce the problem?
Run this test: 
$.htmlClean.defaults.allowedTags = ["p", "em", "h1"];
$.htmlClean.defaults.removeTags = ["span"];
var test = '<span><h1>My big Heading</h1></span>'
clean(test, '<h1>My big Heading</h1>');

What is the expected output? What do you see instead?
My intent is to remove all these stupid spans from the html. However
because of line 98 (add = false;) . A heading tag can never exist inside a
inline element.

For me, there needs to be an option to turn this off.


version 1.2.1
$Revision: 47 $

Original issue reported on code.google.com by [email protected] on 6 May 2010 at 4:37

Options are formatted out by default

What steps will reproduce the problem?
1. $.htmlClean('<select><option value="foo">bar</option></select>', {format: 
true});

What is the expected output? What do you see instead?

One would expect to see something like:

    <select>
        <option value="foo">bar</option>
    </select>

but one actually sees:

    <select>bar</select>


What version of the product are you using? On what operating system?

Latest (1.3.1) on Chrome/Linux

Please provide any additional information below.

It seems like this can be fixed by changing line 472 to:
"hr", "i", "input", "img", "ins", "label", "legend", "map", "option", "q",

but adding "option" to the "tags which are inline" (as the comment defines 
"tagInline") seems like the wrong way to solve the problem.

Perhaps the code is using "tagInline" as the default whitelist of tags; that 
would explain the behavior, but I didn't dig deep enough to confirm.  If that 
is intended behavior, it appears rather problematic, as it would seem to 
require users to have to define a whitelist of every tag every time they want 
to format some HTML.

It seems to me that a better behavior would be to leave all tags allowed by 
default, and only start "eating" tags if a whitelist or blacklist is defined.

Original issue reported on code.google.com by [email protected] on 12 Feb 2013 at 10:57

Allow only some inline styles?

What steps will reproduce the problem?
1. Customer pastes text from MSWord into content management area of our app
2. All the MS styles ruin the app look and feel
3. But we need to allow them only to change font color or specific others. 
Dissalow changing of font-family or font-size.

What is the expected output? What do you see instead?
See #3 above. We have a customer who has been given access to modify 
descriptive paragraphs within the app we built for them. We want to give them 
freedom to do some things and your script is perfect for this. But how do we 
allow only some inline styles such as "style=color:" but not change font size 
or family?


What version of the product are you using? On what operating system?
v. 1.3.0 
Windows and Mac


Please provide any additional information below.

Am I missing the setting somewhere in the script? Thanks! 

Original issue reported on code.google.com by [email protected] on 25 Mar 2013 at 6:02

Tag replace not working

i'm building a sort of client manager where the user can insert text content 
through a content-editable div. i want to limit the heading only to H2 so if 
the client pastes a H1 or a H3 then it must become a H2.

For that purpose i use the tag replace option, which strips the headings thar 
aren't H2, but then the H2 tag is not applied. 

Example:

replace:[["h1", "h3"], "h2"]




thanks!

Original issue reported on code.google.com by [email protected] on 5 Nov 2012 at 2:42

tags regexp not accepting snake-case names

What steps will reproduce the problem?
1. html with tag: <my-custom-tag>xxx</my-custom-tag>

What is the expected output? What do you see instead?
expected: <my-custom-tag>xxx</my-custom-tag>
actual: <my>xxx</my>

What version of the product are you using? On what operating system?
1.4.0


Please provide any additional information below.
I fixed it by changing the regex from:
var tagsRE = /(<(\/)?(\w+:)?([\w]+)([^>]*)>)|<!--(.*?--)>/gi;

to:
var tagsRE = /(<(\/)?(\w+:)?([\w-]+)([^>]*)>)|<!--(.*?--)>/gi;

Original issue reported on code.google.com by [email protected] on 17 May 2015 at 12:34

Blank spaces before word removed on <u> tags

Using this configuration:
$.htmlClean.defaults.allowedTags = ['div', 'ol', 'ul', 'li', 'em', 'strong', 
'u', 'br'];

htmlClean removes blank spaces before the start of an <ul> tag 


What is the expected output? What do you see instead?
The <u> tag and content should be kept and the spaces before / after the <u> 
tag should not be removed.

What version of the product are you using? On what operating system?

1.2.3 revision 51

Please provide any additional information below.

line 447 should contain the "ul" tag defined as inline (this solves the issue)

Original issue reported on code.google.com by [email protected] on 30 Apr 2012 at 10:33

XHTML from HTML documents

What steps will reproduce the problem?
1. Just parse some HTML with an IMG tag (HTML style)


What is the expected output? What do you see instead?
I'd expect to see the Image tag intact <img> but I see <img /> even though this 
is an HTML 
document.

What version of the product are you using? On what operating system?
The latest.

Please provide any additional information below.
Perhaps there could be an option regarding what the document type is. Or just 
pick it up from 
the header?

Original issue reported on code.google.com by brendon%[email protected] on 1 May 2010 at 12:25

div elements always removed

I am cleaning the following content:

<strong>Welkom bij BeteoR</strong>
<div><br></div>
<div>Organisatie en Adviesgroep BeteoR verzorgt opdrachten op het gebied van 
HRM voor en met:</div>
<div><br></div>
<div>
<ul>
    <li>Onderwijsinstellingen</li>
    <li>Bedrijven</li>
    <li>Zorg &amp; Welzijn</li>
</ul>
</div>

This is the code:

$.htmlClean(value, {
                format:false, 
                allowedTags:["div","ul","li","br","strong"],
                removeAttrs:["class","style","id"]});
            }

And this is the (incorrect) output:

<strong>Welkom bij BeteoR</strong>
<br />
Organisatie en Adviesgroep BeteoR verzorgt opdrachten op het gebied van HRM 
voor en met:
<br />
OnderwijsinstellingenBedrijvenZorg &amp; Welzijn

Somehow, only strong and br are preserved, even though I told htmlClean to also 
keep div/ul/li values. Any reason why it is doing this? I searched for any 
mention of "div" in the code but there seems to be none, and while there are 
mentions of li and ul, they are still removed.

Original issue reported on code.google.com by [email protected] on 15 Mar 2011 at 11:52

Unwanted class removal.

What steps will reproduce the problem?
1. Adding a class to any HTML element.
2. Run the plugin on the HTML.
3.

What is the expected output? What do you see instead?

For some reason the class attribute is being removed from the element.  I can 
enter <span class="something">Some text</span> and the formatted code comes out 
as <span>Some text</span>.

I have made changes to the original file to allow for some custom attributes 
and it allows them as I have configured.  I have used both my altered config 
and the original js file with the same problem.

What version of the product are you using? On what operating system?

Version 1.2.3 - Windows 7 64BIT

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 1 Aug 2010 at 7:52

Problem with inline style attribute

What steps will reproduce the problem?
1.run this: $.htmlClean('<p style="color: #F00">RED</p>', {format:true, 
allowedAttributes:["style"]});

Shouldn't this retain the style attribute? I am getting: 

<p>
    RED
</p>

Original issue reported on code.google.com by [email protected] on 20 Nov 2014 at 1:30

Exempt Conditional Comment data.

When pasting content from Microsoft Word, additional conditional data is 
included. The `allowComments:false` does not properly remove the content from 
these conditional comments. 

Example: 
{{{
<!--[if gte mso 9]><xml>
     <o:DocumentProperties>
      <o:Template>Normal.dotm</o:Template>
      <o:Revision>0</o:Revision>
      <o:TotalTime>0</o:TotalTime>
      <o:Pages>1</o:Pages>
      <o:Words>15</o:Words>
      <o:Characters>90</o:Characters>
      <o:Company>MeKyel</o:Company>
      <o:Lines>1</o:Lines>
      <o:Paragraphs>1</o:Paragraphs>
      <o:CharactersWithSpaces>110</o:CharactersWithSpaces>
      <o:Version>12.0</o:Version>
     </o:DocumentProperties>
     <o:OfficeDocumentSettings>
      <o:AllowPNG/>
     </o:OfficeDocumentSettings>
    </xml><![endif]--><!--[if gte mso 9]><xml>
     <w:WordDocument>
      <w:Zoom>0</w:Zoom>
      <w:TrackMoves>false</w:TrackMoves>
      <w:TrackFormatting/>
      <w:PunctuationKerning/>
      <w:DrawingGridHorizontalSpacing>18 pt</w:DrawingGridHorizontalSpacing>
      <w:DrawingGridVerticalSpacing>18 pt</w:DrawingGridVerticalSpacing>
      <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
      <w:DisplayVerticalDrawingGridEvery>0</w:DisplayVerticalDrawingGridEvery>
      <w:ValidateAgainstSchemas/>
      <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
      <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
      <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
      <w:Compatibility>
       <w:BreakWrappedTables/>
       <w:DontGrowAutofit/>
       <w:DontAutofitConstrainedTables/>
       <w:DontVertAlignInTxbx/>
      </w:Compatibility>
     </w:WordDocument>
    </xml><![endif]--><!--[if gte mso 9]><xml>
     <w:LatentStyles DefLockedState="false" LatentStyleCount="276">
     </w:LatentStyles>
    </xml><![endif]-->

    <!--[if gte mso 10]>
    <style>
     /* Style Definitions */
    table.MsoNormalTable
            {mso-style-name:"Table Normal";
            mso-tstyle-rowband-size:0;
            mso-tstyle-colband-size:0;
            mso-style-noshow:yes;
            mso-style-parent:"";
            mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
            mso-para-margin:0cm;
            mso-para-margin-bottom:.0001pt;
            mso-pagination:widow-orphan;
            font-size:12.0pt;
            font-family:"Times New Roman";
            mso-ascii-font-family:Cambria;
            mso-ascii-theme-font:minor-latin;
            mso-fareast-font-family:"Times New Roman";
            mso-fareast-theme-font:minor-fareast;
            mso-hansi-font-family:Cambria;
            mso-hansi-theme-font:minor-latin;
            mso-ansi-language:EN-US;}
    </style>
    <![endif]-->



    <!--StartFragment-->

    <p class="MsoNormal"><a href="http://gov.uk">Testing
    section</a><o:p></o:p></p>

    <p class="MsoNormal"><o:p>&nbsp;</o:p></p>

    <p class="MsoNormal"><a href="http://www.gov.uk">Testing another section</a><o:p></o:p></p>

    <!--EndFragment-->

}}}

expected output would be

{{{
<p><a href="http://gov.uk">Testing section</a></p>
<p><a href="http://www.gov.uk">Testing another section</a></p>
}}}

Original issue reported on code.google.com by [email protected] on 24 Sep 2013 at 7:51

Allow everything, just remove specified tags/attributes

Is it possible to prevent the cleaner to remove any tags or attributes, keep 
them as they are in the HTML and just remove specified ones in the removeTag 
and removeAttributes options?

example:
source = $.htmlClean(source, {
format: true,
allowedAttributes: [any],
allowedTags: [any]
removeTags: ["table", "tr", "td"]
});

What is the expected output? What do you see instead?
Keep the HTML as it is, only remove specific tags and attributes.

What version of the product are you using? On what operating system?
1.4.0


Original issue reported on code.google.com by [email protected] on 11 Dec 2014 at 11:43

Some options doesn't work so well...

I have a contenteditable div with some text, images and YouTube video:

<p>Some text</p>
<div class="yt_holder">
<object style="display:block" width="590" height="332">
<param name="movie" value="http://www.youtube.com/v/ADgCYjAtRUY">
<param name="allowFullScreen" value="true">
<param name="allowscriptaccess" value="always">
<param name="wmode" value="opaque">
<embed src="http://www.youtube.com/v/ADgCYjAtRUY" 
type="application/x-shockwave-flash" width="590" height="332" 
allowscriptaccess="always" allowfullscreen="true" wmode="opaque">
</object>
</div>
<p>Anoteher text</p>

I use the following options to keep YouTube code in addition to other text:

$.htmlClean(text, {
    format:false, // I was try to change this
    allowedTags: ["p","em","strong","a","ol","ul", "li","img","object","param","embed","div"],
    allowedClasses: ["yt_holder"],
    allowedAttributes: [["class"],["class", "div"],[["style","width","height"], "object"],[["name","value"], "param"],[["src","type","width","height","allowscriptaccess","allowfullscreen","wmode"], "embed"]],
    replaceStyles: [[/font-weight:\s*bold/i, "strong"], [/font-style:\s*italic/i, "em"]]
});

In addition to numerous attempts and changes(!), I always get the same result:

<p>Some text</p>
<div></div>
<p>Anoteher text</p>

Even AllowedClasses doesn't work well to keep class="yt_holder" at div?

Am I doing something wrong or the script does not work very well?

However, the project is excellent! ;)

Original issue reported on code.google.com by [email protected] on 2 Nov 2012 at 8:32

Publish on NPM

Hi, It would be extremely useful if this could be published to NPM. I can help in this regard if needed.

Thanks

is this a bug?

clean(
  '<div><pre><code class="language-js"><span>bb</span></code></pre><span>aa</span></div>',
  '<div><pre><code class="language-js">bb</code></pre>aa</div>',
  {removeTags:['a','span','br']}
)

src: <div><pre><code 
class="language-js"><span>bb</span></code></pre><span>aa</span></div>

actual  : '<div><pre><code 
class="language-js"><span>bb</span></code></pre>aa</div>'

expected: '<div><pre><code class="language-js">bb</code></pre>aa</div>'

Original issue reported on code.google.com by [email protected] on 2 Feb 2013 at 6:26

Select and Options formatting

The select and option tag are both considered inline and are not formatted as a 
result

Need a more sophisticated way of deciding what to format

<select><option>One</option><option>Two</option></select>

=>

<select>
  <option>One</option>
  <option>Two</option>
</select>

Original issue reported on code.google.com by [email protected] on 11 Jul 2013 at 12:08

data-attributes are still being stripped out

What steps will reproduce the problem?
1. copy htmlClean.js to the directory on the web-server
2. copy clean.html to the same directory
3. open clean.html in the browser

What is the expected output? What do you see instead?
data- attributes should be preserved

What version of the product are you using? On what operating system?
1.4.0 Ubuntu 13.10 Firefox

Please provide any additional information below.
if (tag.allowedAttributes != null && (tag.allowedAttributes.length == 0
    || $.inArray(attrMatch[1], tag.allowedAttributes) > -1)) {
    element.attributes.push(new Attribute(attrMatch[1], attrMatch[2]));
}
The attribute is found in attrMatch but is disallowed beause it is not allowed 
for particular tags. But data- is allowed on any HTML element.

Original issue reported on code.google.com by [email protected] on 7 Apr 2014 at 1:53

Attachments:

New features

Hi,

I made two enhancements to my version of jquery-clean, maybe you would like to 
have them?

Option to remove empty lines or not (<div><br></div>) in order to be compatible 
with contenteditable fields.

replaceStyles can set class as well, ex:
replaceStyles: [
        [/font-weight:\s*bold/i, "strong"],
        [/font-style:\s*italic/i, "i"],
        [/text-align:\s*right/i, "div.align-right"],
        [/text-align:\s*left/i, "div.align-left"],
        [/text-align:\s*justify/i, "div.align-justify"],
        [/vertical-align:\s*super/i, "sup"],
        [/vertical-align:\s*sub/i, "sub"]
    ]

Thanks for your plugin.

Original issue reported on code.google.com by [email protected] on 9 Dec 2013 at 11:55

Browser crash - firefox

The following code results in an unresponsive script and also crashes the 
browser instance at times.

console.log( $.htmlClean("<script>") );

Original issue reported on code.google.com by [email protected] on 27 Jan 2014 at 10:44

Removes attributes whose names contain a hyphen, e.g. html5 'data-' attributes.

Version 1.3.0

Attributes whose name contains a hyphen get removed, even if they are specified 
in the 'allowedAttributes' options.

This causes html5 data attributes (e.g. data-name="John") to be removed.

The cause of this is the 'attrsRE' regular expression in the code:
var attrsRE = /(\w+)=(".*?"|'.*?'|[^\s>]*)/gi;

This permits only word characters in the attribute name, (normally 
[A-Za-z0-9_]).

A fix is to replace it with:
var attrsRE = /([A-Za-z0-9_-]+)=(".*?"|'.*?'|[^\s>]*)/gi;

Original issue reported on code.google.com by [email protected] on 16 Jul 2012 at 10:11

Tags removed that shouldn't with certain chunks of HTML

What steps will reproduce the problem?
1. The following HTML (which is the result of a paste from MS Word 2010 into 
IE9 -- yeah I know, the joy...):

<span lang="EN"><p dir="LTR" align="LEFT">This is a heading 1</p>
</span><font color="#345a8a" size="5" face="Calibri"><font color="#345a8a" 
size="5" face="Calibri"><font color="#345a8a" size="5" 
face="Calibri"></font></font></font><font color="#404040" size="2" 
face="Calibri"><font color="#404040" size="2" face="Calibri"><font 
color="#404040" size="2" face="Calibri"><p dir="LTR" align="LEFT">This is a 
heading 8</p>
</font></font></font><font face="Cambria"><p dir="LTR" align="LEFT">This <b>is 
<i>j<u>ust</u></i></b><i><u> so</u>me</i> text.</p>
<p dir="LTR" align="LEFT">And <i>a bullet list:</i></p><i>

<ul>
<p dir="LTR" align="LEFT"><li>Item 1</li><p></p>
<p dir="LTR" align="LEFT"><li>Item</li></ul></i><ul><li> 2 with a 
</li></ul></font><ul><li><a href="http://smart.pr/"><font face="Cambria"><span 
lang="EN">link</span></font></a></li><p></p></ul>

<font face="Courier New"><span lang="EN"><p dir="LTR" align="LEFT">And an 
image</p></span></font><p dir="LTR" align="LEFT"><font 
face="Cambria">:</font><a href="http://blog.smart.pr/"><img border="0" 
src="Image3.jpg" width="392" height="236"></a></p>

2. Will be cleaned into:

<span>This is a heading 1</span> This is a heading 8 This <strong>is 
<em>just</em></strong> <em>some</em> text. And <em>a bullet list:</em> <em>Item 
1 Item</em> 2 with a<ul><li><a 
href="http://smart.pr/"><span>link</span></a></li></ul> <span>And an 
image</span><p>:<a href="http://blog.smart.pr/"><img src="Image3.jpg" 
width="392" height="236" alt='' /></a></p>

What is the expected output? What do you see instead?

A whole bunch of tags is stripped that shouldn't be, like f.e. the first 'p'.

What version of the product are you using? On what operating system?

This 'over-cleaning' occurs in all browsers (although the only browser that 
ends up creating this obviously problematic HTML is IE9).

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 28 Jul 2011 at 1:22

No way to preserve intended content breaks.

What steps will reproduce the problem?
1.Clean any content containing <p>&nbsp;</p>
2.
3.

What is the expected output? What do you see instead?
I expect <p>&nbsp;</p> to be left alone, since it's used to make blank spaces 
in the flow of text. It is removed. That's sometimes useful, but there seems no 
way to stop it.

What version of the product are you using? On what operating system?
1.3.0 r67
Win 7 64bit, Chrome 26.0.1410.64 m


Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 29 Apr 2013 at 4:27

Allowed Attributes does not support attributes with dash in them

What steps will reproduce the problem?
1. Use setting  allowedAttributes: [["data-hash"], ["data-image"]],
2. data-hash and data-image attributes will still be removed

What is the expected output? What do you see instead?
These attributes should no be removed. I checked with the data attribute, it 
worked as expected.


What version of the product are you using? On what operating system?
1.3.0

Original issue reported on code.google.com by [email protected] on 23 May 2012 at 9:04

Meta tag lost all its attributes

What steps will reproduce the problem?

<!DOCTYPE HTML>
<html lang="en-US">

  <head>
    <meta charset="utf-8">
  </head>
  <p>
    <a href="http://www.webpagesthatsuck.com/worst-websites-of-2010-contenders.html" target="_blank">
      Worst Websites of 2010: The Contenders
    </a>
  </p>
</div>
  </SPAN>

What is the expected output? What do you see instead?
meta tag showing like this...
 <meta/>

What version of the product are you using? On what operating system?


Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 28 Mar 2012 at 2:52

Does not work in IE8 with jQuery 1.9.1 $.inArray

What steps will reproduce the problem?
1. Using jQuery 1.9.1
2. Internet Explorer 8.0
3. Try a sanitation.

What is the expected output? What do you see instead?

    Object expected
    at jquery-1.9.1.js:714


What version of the product are you using? On what operating system?
Latest release on Windows 7 using IE8

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 22 May 2013 at 12:58

htmlclean Moves Children Out From Under Their Parent

What steps will reproduce the problem?

1. var html = '<span><div></div></span>';
2. var options = {allowedAttributes: true, allowEmpty: ['div', 'span'], format: 
true, formatIndent: 0};
3. $.htmlClean(html, options)

What is the expected output? What do you see instead?

Expected: "<span>
<div>
</div>
</span>"

Actual: "<span></span>
<div>
</div>"

Note that the inner div got moved from inside the span to outside it.

It's worth noting though that this is an improvement over 1.3.1, which would 
completely remove the inner div.

What version of the product are you using? On what operating system?
1.4.0, Chrome, Linux

Original issue reported on code.google.com by [email protected] on 16 Jan 2014 at 6:31

feature request

hi,

maybe you could add the following feature for the next version:

add allowedAttributes: eg. ["id", "class", "style"] (and clean out all others)

thx

Original issue reported on code.google.com by [email protected] on 8 Apr 2010 at 2:11

browser freeze


This code seems to freeze the browser (chrome)

console.log( $.htmlClean("test <script test") );

Original issue reported on code.google.com by [email protected] on 7 Aug 2013 at 1:11

Unable to clean Deprecated HTML tags and attributes

What steps will reproduce the problem?
1. enter deprecated HTML tags and attributes, eg <font> or <p align="center">

What is the expected output? What do you see instead?
<font> tag should be removed since it is deprecated.  <p algin="center"> should 
return a <p>

What version of the product are you using? On what operating system?
jquery-clean version 1.2.3

Please provide any additional information below.
Perhaps can add in a new options, removedDeprecated - true|false to remove 
deprecated HTML tags and attributes.

Original issue reported on code.google.com by [email protected] on 11 Oct 2010 at 6:30

unwraped text

On a contenteditable div i want that all inserted text becomes wrapped in p 
tags.

Like a plugin option that automatticaly wraps the unwrapped strings of text in 
a default tag chosen by the user.

Does it make sense? Is it an option that once included may be useful?


Thanks and congrats for the plugin ;)

Tony

Original issue reported on code.google.com by [email protected] on 5 Nov 2012 at 3:07

You can't allow iframe tag

What steps will reproduce the problem?
1. var opt = {allowedTags: ['iframe,'...], removeTags:[]}
2. run htmlClean(htmlCodeWithIframe, opt)
3. iframe tags are not kept

What is the expected output? What do you see instead?
jquery-clean still remove iframe tags..

What version of the product are you using? On what operating system?
vers. 1.3.0 

Please provide any additional information below.

It's possible to allow iframe by editing some internal variables 
(tagInline,tagAllowEmpty,tagAttributes)... 

Original issue reported on code.google.com by [email protected] on 20 Jun 2013 at 10:08

adding attributes to td, th tags

What steps will reproduce the problem?
1. In tagAttributes, add "colspan" as an allowed attribute to either td or th 
tags (on the plugin JS file)
2. Run clean on some passed html
3. colspan attributes are not kept

What is the expected output? What do you see instead?
td and th tags keep "colspan" attributes

What version of the product are you using? On what operating system?
version 1.2.0, on windows server 2003 rc2

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 6 Jul 2010 at 12:21

Missing self closing tags

Some self closing tags are missing. Currently, the plugin only 
considers the following self closing tags:

"br", "hr", "img", "link", "meta"

Here's the complete list:
http://xahlee.info/js/html5_non-closing_tag.html

Thanks so much for your plugin :)
Gonzalo.

Original issue reported on code.google.com by [email protected] on 13 Aug 2012 at 8:43

Not expected output for select tag

What steps will reproduce the problem?
1. Used demo site http://www.antix.co.uk/Content/Demos/jQuery-htmlClean/Test.htm
2.Entered code :
<select name="dept" style="width:200px;" multiple ><option value="aa" 
>aitem1</option><option value="bb" selected=1>bitem2</option><option value="cc" 
>bitem3</option><option   >ditem4</option><option   >eitem5</option></select>
3.checked format

What is the expected output? What do you see instead?
Expected:
<select name="dept" style="width:200px;" multiple>
    <option value="aa">aitem1</option>
    <option value="bb" selected=1>bitem2</option>
    <option value="cc">bitem3</option>
    <option>ditem4</option>
    <option>eitem5</option>
</select>

Got op:

<select name="dept"><option value="aa">aitem1</option><option value="bb" 
selected='1'>bitem2</option><option 
value="cc">bitem3</option><option>ditem4</option><option>eitem5</option></select
>

Original issue reported on code.google.com by [email protected] on 11 Jul 2013 at 10:31

Attachments:

all attributes are removed automatically if not specified

Clean:
<div id="test">Hello</div>

I expect:
<div id="test">Hello</div>

I get:
<div>Hello</div>


I fix changing line 111
//Not specifiyng is like allowing all
                   else{
                       element.attributes.push(new Attribute(attrMatch[1], attrMatch[2]));
                   }

Probably an option is better.

Original issue reported on code.google.com by [email protected] on 1 Jul 2011 at 12:31

Not working on this site. Stripping code pieces.

What steps will reproduce the problem?
1. Vist: http://www.w3schools.com/tags/tag_textarea.asp
2. Inspect div id ="main" and copy as HTML (or copy the HTML from 
http://codepen.io/anon/pen/Jtizx)
3. Now try cleaning it at 
http://www.antix.co.uk/Content/Demos/jQuery-htmlClean/Test.htm

What is the expected output? What do you see instead?
Unescaped HTML


What version of the product are you using? On what operating system?
Latest demo and product. OS is windows

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 13 Oct 2013 at 7:16

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.