Skip to content

Commit

Permalink
[3.0.34] Fix backend and fronted bugs
Browse files Browse the repository at this point in the history
 - [back] Password share relative links
 - [front] Sub table search
 - [front] Order table first line
  • Loading branch information
mauricelambert authored May 23, 2024
1 parent 53f3a6a commit 208a343
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 29 deletions.
28 changes: 5 additions & 23 deletions WebScripts/scripts/passwords/new_password_share.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

###################
# This file can share a password securely
# Copyright (C) 2021, 2022, 2024 Maurice Lambert
# Copyright (C) 2021, 2022, 2023, 2024 Maurice Lambert

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -25,7 +25,7 @@
This file can share a password securely.
"""

__version__ = "1.0.1"
__version__ = "1.0.2"
__author__ = "Maurice Lambert"
__author_email__ = "mauricelambert434@gmail.com"
__maintainer__ = "Maurice Lambert"
Expand All @@ -39,7 +39,7 @@
__url__ = "https://github.com/mauricelambert/WebScripts"

copyright = """
WebScripts Copyright (C) 2021, 2022, 2024 Maurice Lambert
WebScripts Copyright (C) 2021, 2022, 2023, 2024 Maurice Lambert
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions.
Expand Down Expand Up @@ -144,29 +144,11 @@ def get_printable(password: bytes, key: bytes) -> Tuple[str, str]:

def get_url(token: str) -> str:
"""
This function build an URL to get
This returns the relative URL to get
the password share.
This function comes from PEP-3333:
- https://www.python.org/dev/peps/pep-3333/#url-reconstruction
"""

url = environ["wsgi.url_scheme"] + "://"

if environ.get("HTTP_HOST"):
url += environ["HTTP_HOST"]
else:
url += environ["SERVER_NAME"]

if environ["wsgi.url_scheme"] == "https":
if environ["SERVER_PORT"] != "443":
url += ":" + environ["SERVER_PORT"]
else:
if environ["SERVER_PORT"] != "80":
url += ":" + environ["SERVER_PORT"]

url += f"get_password_share.py?token={quote(token)}"
return url
return "./get_password_share.py?token=" + quote(token)


def main() -> int:
Expand Down
2 changes: 1 addition & 1 deletion WebScripts/static/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#9286C2">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>__init__</strong></big></big> (version 3.0.33)</font></td
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>__init__</strong></big></big> (version 3.0.34)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="__init__.py">__init__.py</a></font></td></tr></table>
<p><tt>This&nbsp;tool&nbsp;runs&nbsp;CLI&nbsp;scripts&nbsp;and&nbsp;displays&nbsp;output&nbsp;in&nbsp;a&nbsp;Web&nbsp;Interface.</tt></p>
Expand Down
9 changes: 5 additions & 4 deletions WebScripts/static/js/webscripts_script_js_scripts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Scripts for script.html
Copyright (C) 2021, 2022 Maurice Lambert
Copyright (C) 2021, 2022, 2024 Maurice Lambert
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1338,18 +1338,19 @@ class ShortTable {
let table = this.closest('table');
let id = Array.from(this.parentNode.children).indexOf(this);

Array.from(table.querySelectorAll('tr:nth-child(n+2)'))
Array.from(table.querySelectorAll('tbody > tr'))
.filter(tr => table == tr.closest('table'))
.sort(ShortTable.prototype.get_callback(id, window.ascendant = !
window.ascendant))
.forEach(line => table.appendChild(line));
.forEach(line => line.parentNode.appendChild(line));
}

/*
This function adds listeners on each table headers.
*/
add_listeners() {

document.querySelectorAll('th').forEach((header) => {
Array.from(document.querySelectorAll('th')).forEach((header) => {
if (!header.have_short_event) {
header.addEventListener('click', ShortTable
.prototype.event.bind(header));
Expand Down
2 changes: 1 addition & 1 deletion WebScripts/static/templates/script.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<link rel="stylesheet" type="text/css" href="%(subpath)sstatic/webscripts_style.css" integrity="sha512-hn9MUcYe4YQLkgIXDHwxakJ89R4IZl/M3RbJLcJsw8NjkPKyviVLuGj/TVQ016w7upj6x2TVbOhXqJBRwhZ5Cg==">
<link rel="stylesheet" type="text/css" href="%(subpath)sstatic/webscripts_script_style.css" integrity="sha512-sRgxcUILghgOO/kSIGuJ/GaTsu0IMhKPMCeToWrQHjm1puraV0yqi476xMZrVNiKd+hAWCxrR39jxJdyylmDnA==">
<script type="text/javascript" src="%(subpath)sjs/webscripts_js_scripts.js" integrity="sha512-uAGwtr6/fo9DjmY3UipxyYIFWGq4eDPWPa2iYMTFX5TPh3f+LPTyTG+CASiH3z8PK9Qf8VIyfzd8yZmycVJkwg=="></script>
<script type="text/javascript" src="%(subpath)sjs/webscripts_script_js_scripts.js" integrity="sha512-OjcVV+fQY6xheL8919kMQkV24qWeqBSTFDSs3YDGG1gwZQymaEdR1aNak3Xjr/quIergwh/zg48v4d7caOSzPQ=="></script>
<script type="text/javascript" src="%(subpath)sjs/webscripts_script_js_scripts.js" integrity="sha512-qb2wIBtSsCrrs8/Z7hjMDMvKJ6sT4n3NepWhyuHsw0+ncr5xMXTY6Y4bPImjinFtgEPKbubPyK896IreKgM5JA=="></script>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; navigate-to 'self'; worker-src 'none'; style-src-elem 'self'; style-src-attr 'none'; style-src 'self'; script-src-attr 'none'; object-src 'none'; media-src 'none'; manifest-src 'none'; connect-src 'self'; font-src 'none'; img-src 'self'; base-uri 'none'; child-src 'none'; form-action 'none'; script-src 'self' 'nonce-%(nonce)s' 'require-trusted-types-for'">
</head>

Expand Down

0 comments on commit 208a343

Please sign in to comment.