Update block_requests.py to resolve unexpected type error (500 error) (#5976)

This commit is contained in:
Louis Del Valle 2024-06-23 23:56:51 -05:00 committed by GitHub
parent 125bb7b03b
commit 57119c1b30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -43,19 +43,19 @@ def my_open(*args, **kwargs):
with original_open(*args, **kwargs) as f: with original_open(*args, **kwargs) as f:
file_contents = f.read() file_contents = f.read()
file_contents = file_contents.replace(b'\t\t<script\n\t\t\tsrc="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.9/iframeResizer.contentWindow.min.js"\n\t\t\tasync\n\t\t></script>', b'') file_contents = file_contents.replace('\t\t<script\n\t\t\tsrc="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.9/iframeResizer.contentWindow.min.js"\n\t\t\tasync\n\t\t></script>', '')
file_contents = file_contents.replace(b'cdnjs.cloudflare.com', b'127.0.0.1') file_contents = file_contents.replace('cdnjs.cloudflare.com', b'127.0.0.1')
file_contents = file_contents.replace( file_contents = file_contents.replace(
b'</head>', '</head>',
b'\n <script src="file/js/katex/katex.min.js"></script>' '\n <script src="file/js/katex/katex.min.js"></script>'
b'\n <script src="file/js/katex/auto-render.min.js"></script>' '\n <script src="file/js/katex/auto-render.min.js"></script>'
b'\n <script src="file/js/highlightjs/highlight.min.js"></script>' '\n <script src="file/js/highlightjs/highlight.min.js"></script>'
b'\n <script src="file/js/highlightjs/highlightjs-copy.min.js"></script>' '\n <script src="file/js/highlightjs/highlightjs-copy.min.js"></script>'
b'\n <script>hljs.addPlugin(new CopyButtonPlugin());</script>' '\n <script>hljs.addPlugin(new CopyButtonPlugin());</script>'
b'\n </head>' '\n </head>'
) )
return io.BytesIO(file_contents) return io.StringIO(file_contents)
else: else:
return original_open(*args, **kwargs) return original_open(*args, **kwargs)