Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
aa.gusti
/
opensipkd-tools
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7eb60584
authored
Feb 06, 2026
by
aa.gustiana@gmail.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: update file upload handling and improve extension validation in Upload class
1 parent
5991130f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
12 deletions
opensipkd/tools/__init__.py
opensipkd/tools/pbb.py
opensipkd/tools/__init__.py
View file @
7eb6058
...
...
@@ -492,6 +492,7 @@ class Upload(SaveFile):
return
fullpath
def
save
(
self
,
request
,
name
,
exts
=
None
,
filename
=
None
):
"""Single file upload"""
input_file
=
request
.
POST
[
name
]
.
file
ext
=
get_ext
(
request
.
POST
[
name
]
.
filename
)
ext
=
ext
and
ext
.
lower
()
or
None
...
...
@@ -502,16 +503,30 @@ class Upload(SaveFile):
head
,
filename
=
os
.
path
.
split
(
filename
)
return
filename
def
save_fp
(
self
,
upload
):
if
'fp'
not
in
upload
or
upload
[
'fp'
]
==
b
''
or
not
upload
[
'fp'
]
or
not
\
upload
[
'size'
]:
if
"filename"
in
upload
:
return
upload
[
'filename'
]
return
filename
=
upload
[
'filename'
]
input_file
=
upload
[
'fp'
]
ext
=
get_ext
(
filename
)
filename
=
self
.
save_to_file
(
input_file
,
ext
)
def
save_fp
(
self
,
upload
,
exts
=
None
,
filename
=
None
):
"""Object FieldStorage"""
if
isinstance
(
upload
,
dict
):
if
'fp'
not
in
upload
or
upload
[
'fp'
]
==
b
''
or
not
upload
[
'fp'
]
or
not
\
upload
[
'size'
]:
if
"filename"
in
upload
:
return
upload
[
'filename'
]
return
file_name
=
upload
[
'filename'
]
input_file
=
upload
[
'fp'
]
else
:
if
not
hasattr
(
upload
,
"fp"
)
or
upload
.
fp
==
b
''
or
not
upload
.
fp
or
not
\
upload
.
bytes_read
:
if
upload
.
filename
:
return
upload
.
filename
return
file_name
=
upload
.
filename
input_file
=
upload
.
fp
ext
=
get_ext
(
file_name
)
if
exts
and
ext
not
in
exts
:
raise
InvalidExtension
(
exts
)
filename
=
self
.
save_to_file
(
input_file
,
ext
,
filename
=
f
"{filename}{ext}"
if
filename
else
None
)
return
os
.
path
.
split
(
filename
)[
1
]
def
saves
(
self
,
uploads
):
...
...
opensipkd/tools/pbb.py
View file @
7eb6058
...
...
@@ -61,7 +61,7 @@ NOPEL.extend([('tahun', 4, 'N'),
(
'bundel'
,
4
,
'N'
),
(
'urut'
,
3
,
'N'
)])
NOPELDET
=
list
(
NOPEL
)
NOPELDET
.
extend
(
list
(
NOP
))
NOPELDET
.
extend
(
list
(
SPPT
))
AGENDA
=
[
(
'kd_seksi'
,
2
,
'N'
),
...
...
@@ -96,7 +96,7 @@ class SetFixLength(FixLength):
class
BaseFixLength
(
SetFixLength
):
def
__init__
(
self
,
raw
):
super
(
BaseFixLength
,
self
)
.
__init__
(
raw
,
self
.
get_structure
())
raw
=
re
.
sub
(
"
\
D"
,
""
,
raw
)
raw
=
re
.
sub
(
r
"\D"
,
""
,
raw
)
self
.
set_raw
(
raw
)
def
get_structure
(
self
):
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment