AnsweredAssumed Answered

XML response includes extra new line

Question asked by mcalvi on Aug 15, 2014

FYI we found where a response from the v2 API fetch report call will throw an extra new line in the XML response.  The URL is /api/2.0/fo/report/ and the parameter is.

'action' => "fetch",

 

 

We use the QualysGuard perl module and extend it a bit (lot).  It will throw the following error:

 

Missing on unknown DOCTYPE at myQualys/Request.pm line XXX

 

 

If you add the following method into the Request.pm file and modify the _get_qualys_response_from method as bolded, it should fix the issue without excessive impact to the rest of the module

 

# -------------------------------------------------------------------

#   _cleanse - cleanse any errors in the XML

# -------------------------------------------------------------------

sub _cleanse {

        my $self = shift;

        my $content = shift;

 

        if( $content =~ m/\<\?xml version=\"1.0\" encoding=\"UTF-8\" \?\>\n\n/ )

        {

                $content =~ s/\n\n/\n/;

        }

 

        return $content;

}

 

 

 

# -------------------------------------------------------------------

#   Factory method that creates the appropriate Response Object

# -------------------------------------------------------------------

sub _get_qualys_response_from {

    my ( $self, $http_response ) = @_;

    my $function      = $self->{function};

    my $xml_content   = $self->_cleanse($http_response->content()) ;

#     my $xml_content   = $http_response->content() ;

     my $qualys_return = undef;

 

The XML changes from

<?xml version="1.0" encoding="UTF-8" ?>

 

<!DOCTYPE ASSET_DATA_REPORT SYSTEM "https://qualysguard.qualys.com/asset_data_report.dtd">

<ASSET_DATA_REPORT>

  <HEADER>

........

 

to

 

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE ASSET_DATA_REPORT SYSTEM "https://qualysguard.qualys.com/asset_data_report.dtd">

<ASSET_DATA_REPORT>

  <HEADER>

........

 

Message was edited by: Michael Calvi for more detail.

Outcomes