Item14007: weird malfunction in INCLUDE
Priority: Low
Current State: Confirmed
Released In: n/a
Target Release: n/a
Applies To: Engine
Component: INCLUDE
Branches:
I have some code which I want to INCLUDE from a file over in pub.
Here's a cut-down version that exhibits the problem:
// foo!
for (int i=0; i<lim_cycles; i++) {
}
//SYSIN DD DUMMY
As shown above, this code renders properly when it's located in the topic page.
However, it does
not render properly when I bring it in from another file.
Specifically, all of the line breaks following the "for" line go away, like this:
// foo!
for (int i=0; i<lim_cycles; i++) { } //SYSIN DD DUMMY
The INCLUDE line I was using when the bug surfaced was something like this:
%INCLUDE{"http://foswiki.org./pub/.../foo.txt"}%
I can work around the problem by changing the line to something like this:
%INCLUDE{"http://foswiki.org./pub/.../foo.txt" raw="on"}%
Live example
%INCLUDE{"%ATTACHURL%/foo.txt"}%
// foo!
for (int i=0; i<lim_cycles; i++) { } //SYSIN DD DUMMY
--
RichMorin - 05 Mar 2016
When you include a URL, it's treated as an HTML page, and renders per the normal HTML rendering. Whitespace on adjacent lines is never preserved in HTML unless it's part of a <pre> block. But in this case that won't work either because your text file contains unescaped < as well. I think you've found the right solution.
--
GeorgeClark - 05 Mar 2016
I think it's the unescaped < in the text. the
INCLUDE of URLs' is documented as:
:
- ) Alter relative links to point back to originating host,
- ) Remove some basic HTML tags (html, head, body, script) and finally
- ) Remove newlines from HTML tags spanning multiple lines. (This compression step rewrites unmatched <'s into
<
entities unless bypassed)
I suspect that it's this last option. The unmatched < is subject to tag compression first, removing the blank lines, and then converted to the entity.
Confirmed, yes, it's the tag compression. Processing HTML using regular expressions can be difficult. I'll confirm the task, but it needs a developer interested in rewriting the parser in
Foswiki::IncludeHandlers::http
.
--
GeorgeClark - 05 Mar 2016
"the unescaped < in the text"
Inside a verbatim, inside an
INCLUDE, a < is used?
That feels like a bug to me. There's a
verbatim in there.
--
VickiBrown - 05 Mar 2016
I already confirmed the task as a bug. But remember,
INCLUDE of a
http:// web page is including HTML not topic markup. The include code doesn't look for any TML / pseudo-HTML, like verbatim tags. It just happens to go through our rendering on the way to a topic. But
INCLUDE process HTML received via HTTP get. verbatim is not HTML.
--
GeorgeClark - 06 Mar 2016
Test with at textarea: