Ignore large block of text

General questions about using ExamDiff Pro, ideas for new features, bug reports, and usage tips.
Post Reply
AlexFeren
New Member
Posts: 6
Joined: Thu Feb 22, 2024 12:29 pm

Ignore large block of text

Post by AlexFeren »

Hello!
Fortigate configuration file has a large block of text containing PEM-formatted certificate and key, which get updated at every backup.

For example:

Code: Select all

        set private-key "-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABCGR2b7mr
:
:
qcRimIuw==
-----END OPENSSH PRIVATE KEY-----"
I'd like ExamDiff ignore it. How can I do?
R's, Fern.
Last edited by AlexFeren on Wed Feb 28, 2024 7:15 pm, edited 1 time in total.
User avatar
psguru
Site Admin
Posts: 2232
Joined: Sat May 15, 2004 4:23 pm
Location: California
Contact:

Re: Ignore large block of text

Post by psguru »

If these lines have consistent line numbers (say from line 1 to line 7), you can ignore then by line ranges (under Options | Text Comparison).
psguru
PrestoSoft
AlexL
Expert Member
Posts: 129
Joined: Wed Aug 11, 2004 6:25 am
Location: Israel
Contact:

Re: Ignore large block of text

Post by AlexL »

You publushed your question in the forum of ExamDiff Pro, but the question wording mentions ExamDiff.
I'll assume that you meant ExamDiff Pro.
In this case, I would try the following:
Menu -> Tools -> Options... -> Text Comparison -> Ignore lines -> Line ranges
And specify there the exact amount of lines to ignore, I think it's 7 lines in your case.
By the way, when you have entered that configuration menu, you can use <F1> button to get help about format of specifying the number (or even range) of ignored lines.
Don't forget to remove this setting when you compare other files which do not need such ignoration. Settings are saved.
AlexFeren
New Member
Posts: 6
Joined: Thu Feb 22, 2024 12:29 pm

Re: Ignore large block of text

Post by AlexFeren »

Hello! No, the line numbers for these blocks of text aren't static - varying each time the configuration backup is generated. Moreover, their length isn't static - hence PEM format specifies the delimiters. Moreover, there are multiples of these spread out through the configuration file...
User avatar
psguru
Site Admin
Posts: 2232
Joined: Sat May 15, 2004 4:23 pm
Location: California
Contact:

Re: Ignore large block of text

Post by psguru »

Then another option is to use the ignore regular expressions option, if you can come with one that is. These can be multi-line.
psguru
PrestoSoft
AlexFeren
New Member
Posts: 6
Joined: Thu Feb 22, 2024 12:29 pm

Re: Ignore large block of text

Post by AlexFeren »

> Then another option is to use the ignore regular expressions option, if you can come with one that is. These can be multi-line.
Surely, a ExamDiff can make this easier by implementing "Ignore multi-line text bounded by start and end text" feature?
User avatar
psguru
Site Admin
Posts: 2232
Joined: Sat May 15, 2004 4:23 pm
Location: California
Contact:

Re: Ignore large block of text

Post by psguru »

Yes, it would be but it's never come up until now. For now, you can create a new document type and define your own "comments" for it using a regular expression, like this for C comments:

Code: Select all

/\\*.*?\\*/
psguru
PrestoSoft
AlexFeren
New Member
Posts: 6
Joined: Thu Feb 22, 2024 12:29 pm

Re: Ignore large block of text

Post by AlexFeren »

Hi... Can you propose the regular expression given the specification in previous post?
User avatar
psguru
Site Admin
Posts: 2232
Joined: Sat May 15, 2004 4:23 pm
Location: California
Contact:

Re: Ignore large block of text

Post by psguru »

Are there unique start/end words that delimit your "comments"? If so, use something like:

Code: Select all

word1.*?word2
psguru
PrestoSoft
AlexFeren
New Member
Posts: 6
Joined: Thu Feb 22, 2024 12:29 pm

Re: Ignore large block of text

Post by AlexFeren »

Are there unique start/end words that delimit your "comments"?
This:

Code: Select all

        set private-key "-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABCGR2b7mr
:
:
qcRimIuw==
-----END OPENSSH PRIVATE KEY-----"
AlexFeren
New Member
Posts: 6
Joined: Thu Feb 22, 2024 12:29 pm

Re: Ignore large block of text

Post by AlexFeren »

psguru wrote: Mon Feb 26, 2024 10:31 am For now, you can create a new document type and define your own "comments" for it using a regular expression, like this for C comments:
Suggestions?
User avatar
psguru
Site Admin
Posts: 2232
Joined: Sat May 15, 2004 4:23 pm
Location: California
Contact:

Re: Ignore large block of text

Post by psguru »

I gave you a suggestion earlier: use a regex like this

Code: Select all

word1.*?word2
where word1/2 are unique starting/ending texts of the ignored block.
psguru
PrestoSoft
JeremyNicoll
Expert Member
Posts: 108
Joined: Sun May 02, 2010 12:00 pm
Location: Edinburgh

Re: Ignore large block of text

Post by JeremyNicoll »

Perhaps another option would be to write a simple 'plugin' which strips out the blocks of lines
you're not interested in. Possibly you'd want the plugin to leave a single line where each such
block had been saying "There was a key definition here." or even (if the number of them
matters) "Key definition nnnnn was here."
Post Reply