Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

fix: Infinite loop issue #507

Merged
merged 1 commit into from
Oct 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
CATCH_NO_EXCEPT,
);
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "./test/**";
USER_HEADER_SEARCH_PATHS = "../../../../test/**";
};
name = Debug;
};
Expand All @@ -329,7 +329,7 @@
CLANG_CXX_LANGUAGE_STANDARD = "c++14";
GCC_PREPROCESSOR_DEFINITIONS = CATCH_NO_EXCEPT;
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "./test/**";
USER_HEADER_SEARCH_PATHS = "../../../../test/**";
};
name = Release;
};
Expand Down
4 changes: 2 additions & 2 deletions ext/snowcrash/snowcrash.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -719,15 +719,15 @@
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "./ext/markdown-parser/src/** ./ext/markdown-parser/ext/sundown/src/** ./test/**";
USER_HEADER_SEARCH_PATHS = "./ext/markdown-parser/src/** ./ext/markdown-parser/ext/sundown/src/** ../../test/**";
};
name = Debug;
};
BBFF48C8170B3C30001E5FB2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "./ext/markdown-parser/src/** ./ext/markdown-parser/ext/sundown/src/** ./test/**";
USER_HEADER_SEARCH_PATHS = "./ext/markdown-parser/src/** ./ext/markdown-parser/ext/sundown/src/** ../../test/**";
};
name = Release;
};
Expand Down
6 changes: 3 additions & 3 deletions ext/snowcrash/src/BlueprintParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ namespace snowcrash

contextSectionType = sectionType;
contextCur = cur;
} else if (contextSectionType != DataStructureGroupSectionType) {
} else if (contextSectionType != DataStructureGroupSectionType
&& SectionProcessor<Action>::sectionType(cur) == ActionSectionType) {
Copy link
Member

@kylef kylef Oct 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering what the difference would be between SectionProcessor<Action>::sectionType(cur) == ActionSectionType and sectionType == ActionSectionType. Could you please explain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sectionType will be UndefinedSectionType because in BlueprintParser's nestedSectionType(), we don't check for ActionType since it is not a direct child of Blueprint.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is still passing with this though: d92137c

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember other tests failing with that. It is the first thing I tried too.


contextSectionType = UndefinedSectionType;
}
Expand All @@ -190,8 +191,7 @@ namespace snowcrash
if (contextSectionType == DataStructureGroupSectionType) {

if (sectionType != MSONSampleDefaultSectionType && sectionType != MSONPropertyMembersSectionType
&& sectionType != MSONValueMembersSectionType
&& sectionType != UndefinedSectionType
&& sectionType != MSONValueMembersSectionType && sectionType != UndefinedSectionType
&& sectionType != DataStructureGroupSectionType) {

contextSectionType = UndefinedSectionType;
Expand Down
19 changes: 19 additions & 0 deletions ext/snowcrash/test/test-BlueprintParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1480,3 +1480,22 @@ TEST_CASE("Parse blueprint with escaped data structure reference", "[blueprint]"
REQUIRE(blueprint.node.content.elements().at(0).element == Element::CategoryElement);
REQUIRE(blueprint.node.content.elements().at(0).content.elements().size() == 1);
}

TEST_CASE("Parse blueprint with random header node after resource", "[blueprint]")
{
mdp::ByteBuffer source
= "## Examples [/examples]\n"
"## X\n"
"+ Attributes (Examples)\n"
"# Data Structures\n"
"# Examples (object)\n"
"\n"
"# Y\n";

ParseResult<Blueprint> blueprint;
SectionParserHelper<Blueprint, BlueprintParser>::parse(
source, BlueprintSectionType, blueprint, ExportSourcemapOption, Models(), &blueprint);

REQUIRE(blueprint.report.error.code != Error::OK);
REQUIRE(blueprint.report.warnings.size() == 1);
}
6 changes: 3 additions & 3 deletions test/fixtures/render/issue-328-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
"content": [
{
"element": "number",
"content": 32
"content": 30
},
{
"element": "number",
"content": 15
"content": 18
}
]
}
Expand All @@ -43,7 +43,7 @@
]
}
},
"content": "base type 'C' is not defined in the document"
"content": "base type 'C' circularly referencing itself"
}
]
}
88 changes: 22 additions & 66 deletions test/fixtures/render/issue-328-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,48 @@
"element": "parseResult",
"content": [
{
"element": "category",
"element": "annotation",
"meta": {
"classes": {
"element": "array",
"content": [
{
"element": "string",
"content": "api"
"content": "error"
}
]
},
"title": {
"element": "string",
"content": "API"
}
},
"content": [
{
"element": "category",
"meta": {
"classes": {
"element": "array",
"content": [
{
"element": "string",
"content": "resourceGroup"
}
]
},
"title": {
"element": "string",
"content": ""
}
},
"attributes": {
"code": {
"element": "number",
"content": 4
},
"sourceMap": {
"element": "array",
"content": [
{
"element": "resource",
"meta": {
"title": {
"element": "string",
"content": "C"
}
},
"attributes": {
"href": {
"element": "string",
"content": "/c"
}
},
"element": "sourceMap",
"content": [
{
"element": "copy",
"content": "### Add C(`[POST"
},
{
"element": "dataStructure",
"content": {
"element": "C",
"meta": {
"id": {
"element": "string",
"content": "C"
}
"element": "array",
"content": [
{
"element": "number",
"content": 35
},
{
"element": "number",
"content": 18
}
}
]
}
]
}
]
},
{
"element": "category",
"meta": {
"classes": {
"element": "array",
"content": [
{
"element": "string",
"content": "dataStructures"
}
]
}
},
"content": []
}
]
},
"content": "base type 'C' circularly referencing itself"
},
{
"element": "annotation",
Expand Down