| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,12 +39,8 @@ def TestOneInput(data): | |||
| 39 | 39 | git_config.read() | |
| 40 | 40 | except (MissingSectionHeaderError, ParsingError, UnicodeDecodeError): | |
| 41 | 41 | return -1 # Reject inputs raising expected exceptions | |
| 42 | - except (IndexError, ValueError) as e: | ||
| 43 | - if isinstance(e, IndexError) and "string index out of range" in str(e): | ||
| 44 | - # Known possibility that might be patched | ||
| 45 | - # See: https://github.com/gitpython-developers/GitPython/issues/1887 | ||
| 46 | - pass | ||
| 47 | - elif isinstance(e, ValueError) and "embedded null byte" in str(e): | ||
| 42 | + except ValueError as e: | ||
| 43 | + if "embedded null byte" in str(e): | ||
| 48 | 44 | # The `os.path.expanduser` function, which does not accept strings | |
| 49 | 45 | # containing null bytes might raise this. | |
| 50 | 46 | return -1 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -452,7 +452,7 @@ def _read(self, fp: Union[BufferedReader, IO[bytes]], fpname: str) -> None: | |||
| 452 | 452 | e = None # None, or an exception. | |
| 453 | 453 | ||
| 454 | 454 | def string_decode(v: str) -> str: | |
| 455 | - if v[-1] == "\\": | ||
| 455 | + if v and v.endswith("\\"): | ||
| 456 | 456 | v = v[:-1] | |
| 457 | 457 | # END cut trailing escapes to prevent decode error | |
| 458 | 458 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -142,6 +142,14 @@ def test_multi_line_config(self): | |||
| 142 | 142 | ) | |
| 143 | 143 | self.assertEqual(len(config.sections()), 23) | |
| 144 | 144 | ||
| 145 | + def test_config_value_with_trailing_new_line(self): | ||
| 146 | + config_content = b'[section-header]\nkey:"value\n"' | ||
| 147 | + config_file = io.BytesIO(config_content) | ||
| 148 | + config_file.name = "multiline_value.config" | ||
| 149 | + | ||
| 150 | + git_config = GitConfigParser(config_file) | ||
| 151 | + git_config.read() # This should not throw an exception | ||
| 152 | + | ||
| 145 | 153 | def test_base(self): | |
| 146 | 154 | path_repo = fixture_path("git_config") | |
| 147 | 155 | path_global = fixture_path("git_config_global") | |
| Back | FazBrowse Home | New Git URL |
0 commit comments