Ticket #107 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Editor strips tags containing "s" character

Reported by: PACE Owned by: jf.hovinne
Priority: minor Milestone: 0.5
Component: editor Version: trunk
Keywords: removeEmptyTags Cc:

Description

Whenever a tag only contains the lowercase character "s", the tag including the content gets discarded. E.g., the text "<p>This is <b>s</b>parta!</p>" is returned by the xhtml() function as "<p>This is parta!</p>".

The cause for this is an incorrect regex in the function WYMeditor.XhtmlSaxListener.prototype.removeEmptyTags:

return xhtml.replace(new RegExp('<('+this.block_tags.join("|")+')>(<br \/>|&#160;|&nbsp;|\s)*<\/\\1>' ,'g'),'');

There is a backslash missing before "\s", so it erroneously strips tags containing "s" instead of tags containing whitespaces.

// Correct:
return xhtml.replace(new RegExp('<('+this.block_tags.join("|")+')>(<br \/>|&#160;|&nbsp;|\\s)*<\/\\1>' ,'g'),'');

br, Benjamin

Change History

Changed 2 years ago by jf.hovinne

  • status changed from new to closed
  • resolution set to fixed

Fixed by r500, thanks!

Note: See TracTickets for help on using tickets.