mpenning / ciscoconfparse

Parse, Audit, Query, Build, and Modify Arista / Cisco / Juniper / Palo Alto / F5 configurations.
http://www.pennington.net/py/ciscoconfparse/
GNU General Public License v3.0
793 stars 220 forks source link

(ios) Banners with lines starting with ! do not get parsed correctly #75

Closed Quadrai closed 7 years ago

Quadrai commented 7 years ago

source.ios:

banner motd ^C
!!!  WARNING  !!!
ACCESS IS RESTRICTED TO AUTHORISED PERSONNEL
This managed system is equipped with a security
system intended to prevent and record unauthorized access
attempts. Unauthorized access or use shall render the user
liable to criminal and/or civil prosecution
^C
!
end

Code:

from ciscoconfparse import CiscoConfParse
p = CiscoConfParse("etc/source.ios", debug=True)

[ciscoconfparse init] [DEBUG] 16:33:53 parsing from 'etc/source.ios' with ios syntax [ciscoconfparse _banner_mark_regex] [DEBUG] 16:33:53 banner_lead = 'banner motd' [ciscoconfparse _banner_mark_regex] [DEBUG] 16:33:53 bannerdelimit = '^' [ciscoconfparse _banner_mark_regex] [DEBUG] 16:33:53 banner motd starts at line 1


After a quick look through the code it seems break on the unindented ! as a comment instead of part of the banner.

bandrel commented 7 years ago

just change your comment delimiter to something else other than the default ! and it will work for you.

p = CiscoConfParse("etc/source.ios", debug=True, comment='~')

mpenning commented 7 years ago

Thank you for reporting this issue; I committed a fix in 1.2.47; please test and let me know.

mpenning commented 7 years ago

No feedback since early March 2017, I am closing for now.