aboutsummaryrefslogtreecommitdiffstats
path: root/chromium/chromium/chromium-stub-unrar-wrapper.patch
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/chromium/chromium-stub-unrar-wrapper.patch')
-rw-r--r--chromium/chromium/chromium-stub-unrar-wrapper.patch49
1 files changed, 36 insertions, 13 deletions
diff --git a/chromium/chromium/chromium-stub-unrar-wrapper.patch b/chromium/chromium/chromium-stub-unrar-wrapper.patch
index e97e47c..9a31d31 100644
--- a/chromium/chromium/chromium-stub-unrar-wrapper.patch
+++ b/chromium/chromium/chromium-stub-unrar-wrapper.patch
@@ -57,25 +57,35 @@ index 97f4e0460ad7c..0d665e199e4b4 100644
if (is_win) {
sources += [ "src/isnt.cpp" ]
diff --git a/third_party/unrar/google/unrar_wrapper.cc b/third_party/unrar/google/unrar_wrapper.cc
-index 1b777d2275099..135ba83abbedd 100644
+index a76b497b6ea7d..2f2f159d08071 100644
--- a/third_party/unrar/google/unrar_wrapper.cc
+++ b/third_party/unrar/google/unrar_wrapper.cc
-@@ -9,7 +9,6 @@
- #include "base/files/file_path.h"
+@@ -10,7 +10,6 @@
#include "base/metrics/histogram_macros.h"
+ #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
-#include "third_party/unrar/src/rar.hpp"
namespace third_party_unrar {
-@@ -18,75 +17,10 @@ RarReader::RarReader() {}
+@@ -19,84 +18,10 @@ RarReader::RarReader() {}
RarReader::~RarReader() {}
bool RarReader::Open(base::File rar_file, base::File temp_file) {
- rar_file_ = std::move(rar_file);
- temp_file_ = std::move(temp_file);
-
-- archive_ = std::make_unique<Archive>();
+- command_ = std::make_unique<CommandData>();
+- // Unrar forbids empty passwords, but requires that a password be provided for
+- // encrypted archives. In order to support metadata encryption, we must
+- // provide some password when opening the file.
+- std::wstring password_flag =
+- L"-p" + (password_.empty() ? L"x" : base::UTF8ToWide(password_));
+- command_->ParseArg(password_flag.data());
+- command_->ParseArg(const_cast<wchar_t*>(L"x"));
+- command_->ParseDone();
+-
+- archive_ = std::make_unique<Archive>(command_.get());
- archive_->SetFileHandle(rar_file_.GetPlatformFile());
- archive_->SetTempFileHandle(temp_file_.GetPlatformFile());
-
@@ -87,11 +97,6 @@ index 1b777d2275099..135ba83abbedd 100644
- if (!is_valid_archive)
- return false;
-
-- command_ = std::make_unique<CommandData>();
-- command_->ParseArg(const_cast<wchar_t*>(L"-p"));
-- command_->ParseArg(const_cast<wchar_t*>(L"x"));
-- command_->ParseDone();
--
- extractor_ = std::make_unique<CmdExtract>(command_.get());
- extractor_->ExtractArchiveInit(*archive_);
-
@@ -121,14 +126,18 @@ index 1b777d2275099..135ba83abbedd 100644
- current_entry_.is_encrypted = archive_->FileHead.Encrypted;
- current_entry_.file_size =
- current_entry_.is_directory ? 0 : extractor_->GetCurrentFileSize();
+- current_entry_.contents_valid =
+- success && ErrHandler.GetErrorCode() == RARX_SUCCESS;
+- ErrHandler.Clean();
-
- if (success) {
- return true;
- }
-
- if (archive_->FileHead.Encrypted) {
-- // Since Chromium doesn't have the password, manually skip over the
-- // encrypted data and fill in the metadata we do have.
+- // Since Chromium doesn't have the password or the password was
+- // incorrect, manually skip over the encrypted data and fill in the
+- // metadata we do have.
- archive_->SeekToNext();
- return true;
- }
@@ -145,8 +154,22 @@ index 1b777d2275099..135ba83abbedd 100644
return false;
}
+@@ -105,11 +30,11 @@ void RarReader::SetPassword(const std::string& password) {
+ }
+
+ bool RarReader::HeadersEncrypted() const {
+- return archive_->Encrypted;
++ return false;
+ }
+
+ bool RarReader::HeaderDecryptionFailed() const {
+- return archive_->FailedHeaderDecryption;
++ return true;
+ }
+
+ } // namespace third_party_unrar
diff --git a/third_party/unrar/google/unrar_wrapper.h b/third_party/unrar/google/unrar_wrapper.h
-index 9e5a08bf092b0..01a1f7b023e4c 100644
+index a0724520f0aac..765a7142a962c 100644
--- a/third_party/unrar/google/unrar_wrapper.h
+++ b/third_party/unrar/google/unrar_wrapper.h
@@ -12,9 +12,9 @@