bradchoate / text-textile

Text::Textile -- Perl module for handling Textile format
20 stars 11 forks source link

Fix for wrong escaping in bc #12

Open ghost opened 10 years ago

ghost commented 10 years ago

Hello, I have made a fix and test for problems with bc (see issue https://github.com/bradchoate/text-textile/issues/3)

Please check and add this fix.

ghost commented 10 years ago

Sorry the fix does not work in mixed content with other bc. and bc... Please ignore commit https://github.com/GwenDragon/text-textile/commit/1eea975ee1232b9e9e2bddb7ebc83e2f7caa5e67

ghost commented 10 years ago

In my fix the force of HTML entity encoding is done in code for bc now.

commit https://github.com/GwenDragon/text-textile/commit/a30437f923aea5919bcdef06bce5955f7175a671 works now correctly. I hope. ;)

bradchoate commented 10 years ago

I'll take a closer look; thanks for your patience and persistence. However, this is a breaking change that could affect existing uses of Textile out there. I need to take that into consideration.

ghost commented 10 years ago

@bradchoate Thanks for reply.

However, this is a breaking change that could affect existing uses of Textile out there.

How does my patch violate Textiles behaviour?

As i understood the docs for textiles bc, I thought all text in <code> or <blockcode> should be HTML escaped. Thats means all content for blockcode is HTML escaped to create text-source code, not executable JS or raw HTML elements.

bc
A “bc” signature is short for “block code”, which implies a preformatted section like the 'pre' block, but it also gets a <code> tag (or for XHTML 2, a <blockcode> tag is used instead).

Note that within a “bc” block, < and > are translated into HTML entities automatically.

MoveableType.org: Textile 2 Syntax

bc

A "bc" signature is short for "block code", which implies a preformatted section like the "pre" block, but it also gets a <code> tag (or for XHTML 2, a <blockcode> tag is used instead).

Note that within a "bc" block, < and > are translated into HTML entities automatically.

CPAN Text::Textile

Note that within a "bc" block, < and > are translated into HTML entities automatically.

That means: < translated to &lt;

There is no hint in docs, that bc does skip some HTML elements or XML prolog. Otherwise the documentation is not clear.

HTML docs states for code element:

The <code> element represents a fragment of computer code.

I think it means the raw text, not interpreted as JS or HTML.

Do i misinterpet this so much? Please explain.

If i'm not right, pease add the ability to have a setting running bc in "escaping HTML mode".

PS: I'm a Perl programming webdev and webmistress, HTML is familiar for me. ;)

I need to take that into consideration.

Thanks. And for maintaining the Perl package, not letting it getting orphan.