-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from cicada-solvers/fix-issue-8
Fix issue #8 by detecting message type and calling proper methods + split header validation parsing
- Loading branch information
Showing
56 changed files
with
332 additions
and
1,782 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
/nbproject/private/ | ||
*.ttf | ||
*.otf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.ttf | ||
*.otf | ||
*.woff |
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (C) 2022 crashdemons (crashenator at gmail.com) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
function InitialLineMatcher(section_markers){ | ||
this.reset(); | ||
this.match = null; | ||
this.section_markers = section_markers; | ||
} | ||
|
||
//this is ugly and I hate prototypal inheritance + backporting | ||
InitialLineMatcher.prototype = new Lineparser([],"outside-before"); | ||
|
||
InitialLineMatcher.prototype.change_section_by_marker = function(line){ | ||
for(var i=0;i<this.section_markers.length;i++){ | ||
if(line===this.section_markers[i]){ | ||
this.change_section(0,'message-started',this.section_markers[i]); | ||
this.match = i; | ||
this.stop(); | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (C) 2018 crashdemons (crashenator at gmail.com) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
if (typeof Lineparser === "undefined") { | ||
var Lineparser = {};//suppress warnings in editor - doesn't change anything. | ||
console.error("pgpparser code loaded before Lineparser"); | ||
} | ||
|
||
if (typeof PgpClearsignParser === "undefined") { | ||
var PgpClearsignParser = {};//suppress warnings in editor - doesn't change anything. | ||
console.error("pgpparser code loaded before PgpClearsignParser"); | ||
} | ||
if (typeof PgpSignParser === "undefined") { | ||
var PgpSignParser = {};//suppress warnings in editor - doesn't change anything. | ||
console.error("pgpparser code loaded before PgpSignParser"); | ||
} | ||
|
||
if (typeof InitialLineMatcher === "undefined") { | ||
var InitialLineMatcher = {};//suppress warnings in editor - doesn't change anything. | ||
console.error("pgpparser code loaded before InitialLineMatcher"); | ||
} | ||
|
||
var PgpParsing = { | ||
parsers:{ | ||
CLEARSIGNED: 0, | ||
SIGNED: 1 | ||
}, | ||
guessMessageType:function(cleartext){ | ||
var matcher = new InitialLineMatcher(["-----BEGIN PGP SIGNED MESSAGE-----","-----BEGIN PGP MESSAGE-----"]); | ||
matcher.parse(cleartext); | ||
if(matcher.match!==null) return matcher.match; | ||
return PgpParsing.parsers.CLEARSIGNED;//choose this as default if we cannot determine the type, though this should mean that it is rejected anyway. | ||
}, | ||
|
||
createParser:function(type,line_callback,section_complete_callback){ | ||
console.log("CreateParser",type); | ||
switch(type){ | ||
case PgpParsing.parsers.SIGNED: | ||
return new PgpSignParser(line_callback,section_complete_callback); | ||
case PgpParsing.parsers.CLEARSIGNED: | ||
return new PgpClearsignParser(line_callback,section_complete_callback); | ||
} | ||
return null; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (C) 2018 crashdemons (crashenator at gmail.com) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
if (typeof Lineparser === "undefined") { | ||
var Lineparser = {};//suppress warnings in editor - doesn't change anything. | ||
console.error("pgpparser code loaded before Lineparser"); | ||
} | ||
|
||
//a stateful text-line parser for pgp cleartext messages. | ||
//the line callback is called when each line in a section of the message is processed | ||
//the section-complete callback is called when all data for a section has been collected (the section was ended or moved onto the next section) | ||
function PgpSignParser(line_callback,section_complete_callback){ | ||
this.reset(); | ||
this.line_callback=line_callback; | ||
this.section_complete_callback=section_complete_callback; | ||
this.final.error=0; | ||
this.final.warnings=[]; | ||
} | ||
|
||
//this is ugly and I hate prototypal inheritance + backporting | ||
PgpSignParser.prototype = new Lineparser([ | ||
["sig-headers","-----BEGIN PGP MESSAGE-----"],//define the starting conditions for each section | ||
["signature",""], | ||
["outside-after","-----END PGP MESSAGE-----"] | ||
],"outside-before");//define the initial section name | ||
|
||
//record a fatal error from a callback function (stored in parserobject.final.error) | ||
PgpSignParser.prototype.fail=function(error){ | ||
this.final.error=error; | ||
this.stop(); | ||
}; | ||
|
||
//record a warning from a callback function (stored in parserobject.final.warnings) | ||
PgpSignParser.prototype.warn=function(warning){ | ||
if(this.final.warnings.indexOf(warning)===-1) | ||
this.final.warnings.push(warning); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.