generated from gdt050579/appcui-template
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dropper] + replace regex in text plugin and ad html objects mini-plu…
- Loading branch information
1 parent
8368171
commit 2940e40
Showing
9 changed files
with
419 additions
and
20 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
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,46 @@ | ||
#pragma once | ||
|
||
#include "IDrop.hpp" | ||
|
||
namespace GView::GenericPlugins::Droppper::HtmlObjects | ||
{ | ||
class IFrame : public IDrop | ||
{ | ||
public: | ||
IFrame() = default; | ||
|
||
virtual const std::string_view GetName() const override; | ||
virtual ObjectCategory GetGroup() const override; | ||
virtual const std::string_view GetOutputExtension() const override; | ||
virtual Priority GetPriority() const override; | ||
virtual bool ShouldGroupInOneFile() const override; | ||
|
||
virtual Result Check(uint64 offset, DataCache& file, BufferView precachedBuffer, uint64& start, uint64& end) override; | ||
}; | ||
class Script : public IDrop | ||
{ | ||
public: | ||
Script() = default; | ||
|
||
virtual const std::string_view GetName() const override; | ||
virtual ObjectCategory GetGroup() const override; | ||
virtual const std::string_view GetOutputExtension() const override; | ||
virtual Priority GetPriority() const override; | ||
virtual bool ShouldGroupInOneFile() const override; | ||
|
||
virtual Result Check(uint64 offset, DataCache& file, BufferView precachedBuffer, uint64& start, uint64& end) override; | ||
}; | ||
class XML : public IDrop | ||
{ | ||
public: | ||
XML() = default; | ||
|
||
virtual const std::string_view GetName() const override; | ||
virtual ObjectCategory GetGroup() const override; | ||
virtual const std::string_view GetOutputExtension() const override; | ||
virtual Priority GetPriority() const override; | ||
virtual bool ShouldGroupInOneFile() const override; | ||
|
||
virtual Result Check(uint64 offset, DataCache& file, BufferView precachedBuffer, uint64& start, uint64& end) override; | ||
}; | ||
} // namespace GView::GenericPlugins::Droppper::HtmlObjects |
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
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,65 @@ | ||
#include "HtmlObjects.hpp" | ||
|
||
namespace GView::GenericPlugins::Droppper::HtmlObjects | ||
{ | ||
constexpr std::string_view START{ "<iframe>" }; | ||
constexpr std::string_view END{ "</iframe>" }; | ||
|
||
const std::string_view IFrame::GetName() const | ||
{ | ||
return "IFrame"; | ||
} | ||
|
||
ObjectCategory IFrame::GetGroup() const | ||
{ | ||
return ObjectCategory::HtmlObjects; | ||
} | ||
|
||
const std::string_view IFrame::GetOutputExtension() const | ||
{ | ||
return "iframe"; | ||
} | ||
|
||
Priority IFrame::GetPriority() const | ||
{ | ||
return Priority::Text; | ||
} | ||
|
||
bool IFrame::ShouldGroupInOneFile() const | ||
{ | ||
return false; | ||
} | ||
|
||
Result IFrame::Check(uint64 offset, DataCache& file, BufferView precachedBuffer, uint64& start, uint64& end) | ||
{ | ||
CHECK(precachedBuffer.GetLength() >= START.size(), Result::NotFound, ""); | ||
CHECK(memcmp(precachedBuffer.GetData(), START.data(), START.size()) == 0, Result::NotFound, ""); | ||
|
||
auto buffer = file.Get(offset, file.GetCacheSize() / 12, false); | ||
CHECK(buffer.GetLength() >= START.size() + END.size(), Result::NotFound, ""); | ||
|
||
start = offset; | ||
end = offset; | ||
|
||
uint64 i = 0; | ||
while (buffer.GetLength() >= END.size()) { | ||
CHECK(IsAsciiPrintable(buffer.GetData()[i]), Result::NotFound, ""); | ||
|
||
if (memcmp(buffer.GetData() + i, END.data(), END.size()) == 0) { | ||
end += END.size(); | ||
return Result::Ascii; | ||
} | ||
|
||
end += 1; | ||
i++; | ||
|
||
if (i + END.size() == buffer.GetLength()) { | ||
offset += i + END.size(); | ||
buffer = file.Get(offset, file.GetCacheSize() / 12, false); | ||
i = 0; | ||
} | ||
} | ||
|
||
return Result::NotFound; | ||
} | ||
} // namespace GView::GenericPlugins::Droppper::HtmlObjects |
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,65 @@ | ||
#include "HtmlObjects.hpp" | ||
|
||
namespace GView::GenericPlugins::Droppper::HtmlObjects | ||
{ | ||
constexpr std::string_view START{ "<script>" }; | ||
constexpr std::string_view END{ "</script>" }; | ||
|
||
const std::string_view Script::GetName() const | ||
{ | ||
return "Script"; | ||
} | ||
|
||
ObjectCategory Script::GetGroup() const | ||
{ | ||
return ObjectCategory::HtmlObjects; | ||
} | ||
|
||
const std::string_view Script::GetOutputExtension() const | ||
{ | ||
return "script"; | ||
} | ||
|
||
Priority Script::GetPriority() const | ||
{ | ||
return Priority::Text; | ||
} | ||
|
||
bool Script::ShouldGroupInOneFile() const | ||
{ | ||
return false; | ||
} | ||
|
||
Result Script::Check(uint64 offset, DataCache& file, BufferView precachedBuffer, uint64& start, uint64& end) | ||
{ | ||
CHECK(precachedBuffer.GetLength() >= START.size(), Result::NotFound, ""); | ||
CHECK(memcmp(precachedBuffer.GetData(), START.data(), START.size()) == 0, Result::NotFound, ""); | ||
|
||
auto buffer = file.Get(offset, file.GetCacheSize() / 12, false); | ||
CHECK(buffer.GetLength() >= START.size() + END.size(), Result::NotFound, ""); | ||
|
||
start = offset; | ||
end = offset; | ||
|
||
uint64 i = 0; | ||
while (buffer.GetLength() >= END.size()) { | ||
CHECK(IsAsciiPrintable(buffer.GetData()[i]), Result::NotFound, ""); | ||
|
||
if (memcmp(buffer.GetData() + i, END.data(), END.size()) == 0) { | ||
end += END.size(); | ||
return Result::Ascii; | ||
} | ||
|
||
end += 1; | ||
i++; | ||
|
||
if (i + END.size() == buffer.GetLength()) { | ||
offset += i + END.size(); | ||
buffer = file.Get(offset, file.GetCacheSize() / 12, false); | ||
i = 0; | ||
} | ||
} | ||
|
||
return Result::NotFound; | ||
} | ||
} // namespace GView::GenericPlugins::Droppper::HtmlObjects |
Oops, something went wrong.