()
| 217 | target_path = os.path.abspath(target_path) |
| 218 | |
| 219 | def get_members(): |
| 220 | for member in tarfileobj.getmembers(): |
| 221 | if archive_path: |
| 222 | norm_path = os.path.normpath(member.name) |
| 223 | if norm_path.startswith(archive_path + os.path.sep): |
| 224 | member.name = norm_path[len(archive_path)+1:] |
| 225 | else: |
| 226 | continue |
| 227 | |
| 228 | dst_path = os.path.abspath(os.path.join(target_path, member.name)) |
| 229 | if os.path.commonpath([target_path, dst_path]) != target_path: |
| 230 | # Path not under target_path, probably contains ../ |
| 231 | continue |
| 232 | |
| 233 | yield member |
| 234 | |
| 235 | tarfileobj.extractall(target_path, members=get_members()) |
| 236 |
no test coverage detected