Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def format_whole_file(view, edit, opts):
settings = view.settings()
region = sublime.Region(0, view.size())
code = view.substr(region)
formatted_code = jsbeautifier.beautify(code, opts)
if(settings.get("ensure_newline_at_eof_on_save") and not formatted_code.endswith("\n")):
formatted_code = formatted_code + "\n"
_, err = merge_utils.merge_code(view, edit, code, formatted_code)
if err:
sublime.error_message("JsFormat: Merge failure: '%s'" % err)
def style(self, code):
opts = jsbeautifier.default_options()
opts.end_with_newline = True
opts.operator_position = "preserve-newline"
opts.wrap_line_length = 132
opts.brace_style = "collapse,preserve-inline"
opts.keep_array_indentation = True
return jsbeautifier.beautify(code, opts)
def __call__(self, data, **metadata):
opts = jsbeautifier.default_options()
opts.indent_size = 2
data = data.decode("utf-8", "replace")
res = jsbeautifier.beautify(data, opts)
return "JavaScript", format_text(res)
if not js_name.endswith(".js"):
js_name = js_name[0:js_name.rfind("?")]
# Writes js file
js_file_path = os.path.join("tmp/", first_char, second_char, fdirname, "javascripts", js_name)
if honeypotconfig.proxy:
proxyname = re.search(r":\s?['\"](.*)\s?['\"]", str(honeypotconfig.proxy)).group(1)
js_file_path = os.path.join(proxyname, first_char, second_char, fdirname, "javascripts", js_name)
jswrite = open(js_file_path, 'w')
jswrite.write(response)
if honeypotconfig.jsbeautifier:
jswrite.write("\n====================================================\n")
jswrite.write("====================Beautified Below================\n")
with open(js_file_path , 'a') as f:
beautify_script_string = jsbeautifier.beautify(response, opts)
f.write(str(beautify_script_string))
jswrite.close()
except Exception, e:
logger.error(str(url_no) + ",\t" + url.strip() + ",\t" + '"'+ str(e) + '"'+",\t" + link)
r.close()
jsurl_list_unique.clear()
# Check for executable files and saves them
exe_list = []
path = yourup_soup.find("video", {"id": "player"}).source["src"]
if path.lower() == "undefined":
raise ValueError("") # Failing method 1.
download_url = "https://yourupload.com" + path
if not download_url:
raise ValueError("")
except:
#print(sys.exc_info())
# Method 2 (MP4Upload)
try:
#print("method 2")
for frame in video_frames:
if mp4upload.match(frame["src"]):
mp4up_iframe_source = scraper.get(frame["src"]).content
mp4up_soup = bs(mp4up_iframe_source, "html.parser")
mp4up_js = jsbeautifier.beautify(mp4up_soup.body.find("script", {"type": "text/javascript"}).text)
download_url = re.search(r'src:"(.+\.mp4")', mp4up_js).group(1).replace('"', "")
#print(download_url, url)
if not download_url:
raise ValueError("")
except:
print(sys.exc_info())
failed_episodes.append(episode)
print("Failed to get", episode)
if download_url:
print(episode + ": " + download_url, end="\n\n")
downloads.append(download_url)
hash_map[download_url] = episode
return hash_map, failed_episodes
def write_json(data, this_index, ip):
try:
if os.path.exists("out") == False:
os.makedirs('out')
os.makedirs('out/' + ip)
except OSError as e:
if e.errno != errno.EEXIST:
print (Fore.RED + 'Cannot create directory')
raise
try:
datei = open('out/' + ip + '/' + this_index + '.json', 'a')
datei.write(jsbeautifier.beautify(str(data)))
datei.close()
except FileNotFoundError:
print(Fore.RED + 'Input file not found!')
def format_body(self, body):
return jsbeautifier.beautify(body)
opts = jsbeautifier.default_options()
opts.eval_code = False
# pull indentation from user prefs
use_tab = self.user_settings.get('translate_tabs_to_spaces',False)
if use_tab:
opts.indent_with_tabs = True
else:
opts.indent_char = " "
opts.indent_size = int(self.user_settings.get('tab_size',False))
# pull the rest of settings from our config
for k,v in self.settings.get('jsformat', {}).iteritems():
setattr(opts, k, v)
return jsbeautifier.beautify(codestr, opts)
if option not in OPTIONS:
print "Invalid option"
return False
id = l[1]
response, size = CTCore.get_response_and_size(id, "all")
name = CTCore.get_name(id)
if option == "slice":
offset = int(l[2])
length = l[3]
bytes, length = get_bytes(response,offset,length)
js_bytes = bytes
res = jsbeautifier.beautify(js_bytes)
print res
if option == "obj":
res = jsbeautifier.beautify(response)
obj_num = CTCore.add_object("jsbeautify",res,id=id)
print " JavaScript Beautify of object {} ({}) successful!".format(str(id), name)
print " New object created: {}".format(obj_num) + newLine
except Exception,e:
print str(e)