Skip to content

Commit

Permalink
Spf1: Add option to be less strict when parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrsagen committed Apr 25, 2024
1 parent 4eab992 commit 8cfda4f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alexrsagen/obie",
"version": "1.6.4",
"version": "1.6.5",
"type": "framework",
"description": "Obie is a simple PHP framework. It aims to provide basic services needed for any web app.",
"keywords": ["framework", "php", "http", "template", "view", "router", "routing", "model", "models", "session", "sessions"],
Expand Down
6 changes: 5 additions & 1 deletion src/encoding/spf1.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected static function storeDirective(string &$buf, ?Directive &$directive) {
return true;
}

public static function decode(string $input): ?Record {
public static function decode(string $input, bool $strict = true): ?Record {
$record = new Record();

// check version
Expand Down Expand Up @@ -160,6 +160,10 @@ public static function decode(string $input): ?Record {

// term delimiter
case ' ':
// non-strict: ignore multiple whitespace
if (!$strict && strlen($buf) === 0 && $directive === null) {
break;
}
if (!static::storeDirective($buf, $directive)) return null;
// add the directive to the record
$record->directives[] = $directive;
Expand Down

0 comments on commit 8cfda4f

Please sign in to comment.