Bug 653432

Summary: line numbering of <programlisting> broken
Product: [Community] Publican Reporter: Klaus.Malorny
Component: publicanAssignee: Jeff Fearn <jfearn>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 2.3CC: jfearn, mmcallis, publican-list, r.landmann
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: 2.6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 718717 (view as bug list) Environment:
Last Closed: 2011-07-25 20:42:37 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Klaus.Malorny 2010-11-15 07:56:36 EST
This applies to publican 2.3:

if the linenumbering="numbered" attribute is being set, various problems occur:

* syntax highlighting (via language attribute) no longer works
* line numbering starts a 0 (startinglinenumber not honoured anyway)
* if the content contains < and & (either via CDATA or numeric entities), 
  they are literally interpreted as XML, causing parsing errors

The problems can be traced down to the numberLines function in Builder.pm:

* the node list converted to a string. I guess that syntax highlighting
  happens before, so all generated markup is lost due to this conversion
* the $count variable is initialized to zero, the line number generation
  uses $count++, causing the 0
* the augmented content is then converted back to a document fragment by simply
  parsing the content with an XML parser. As special characters (<, &)
  are not escaped, they are interpreted as XML
Comment 1 Jeff Fearn 2011-03-13 07:11:40 EDT
Hi Klaus, I've committed fixes to startinglinenumber and the use of <, >, etc.

The code highlight fix will take a bit longer, the modified tree isn't being passed to the function so I'll need to track down why it's getting stale data passed in from XSLT.
Comment 2 Jeff Fearn 2011-07-04 08:01:23 EDT
I've cloned this bug to separate the line numbering and sql escaping (this bug) from the line numbering + highlighting not working (717817)

back ported fix to branches/publican-2x
Comment 3 Ruediger Landmann 2011-07-18 00:38:47 EDT
Verified in build 2.5-2.fc15.t14

linenumbering and startinglinenumber attributes working as expected; < and > correctly escaped.