Commit Graph

197 Commits

Author SHA1 Message Date
Jeremy Stanley 1cee24ce0b Support Pillow v10
Pillow 9.5 deprecated the getsize method for fonts in favor of its
new getbbox, and then getsize was removed in Pillow 10.. Adjust the
call we use for captcha generation so it will continue working, and
declare a requirement for the earliest forward-compatible release.

Change-Id: Ib35eea077d7f8c428493ef8e4cfe00e05e580a6f
2024-02-20 21:49:07 +00:00
Clark Boylan fd508a8c19 Replace inspect.getargspec with inspect.signature
Python 3.11 removed the long deprecated inspect.getargspec. Update
lodgeit to use inspect.signature instead. The signature api appears to
be the modern thing that is expected to work into the future.

Change-Id: Ic5603f848c0fffd15d9ce07cd7450638552c82c7
2023-10-09 13:40:10 -07:00
Clark Boylan ac772da1f6 Put regex multiline specifier at beginning of regex string
Python 3.11 appears to want global regex options to be set at the
beginning of the regex string. Setting them elsewhere results in:

  re.error: global flags not at the start of the expression at position foo

A followup change will switch lodgeit over to python3.11 making this
necessary cleanup beforehand.

Change-Id: Idc21e39f7f4e3a9a3bcdc657f0fd6b352a20d617
2023-10-09 11:51:46 -07:00
Ian Wienand bc2678dc73 new paste: check input length
Check the input length, if it's over 64k then this will put up an
error page that says "Could not submit your paste because ..."

Change-Id: I0ba3efbb33050272543b2f76a1cf0f49df26185c
2022-04-20 08:07:44 +10:00
Ian Wienand e22ae1230b new paste: add maxlength to input box
This goes into a mysql "text" type field which is 65,535 characters
long.  Set maxlength just under this to avoid interactive use sending
too much data, which fails with a 502 error currently.

Change-Id: Ieedef0fd956a5d31e682a4c808fb1197b55121b6
2022-04-19 10:27:57 +10:00
Ian Wienand 50d45eddc8 Default to private pastes
This avoids having predictable paste ids by default

Change-Id: Iac86129e6cf9936eb5844b1d3b7b69ee89df8a0e
2022-02-08 11:25:04 +11:00
Jeremy Stanley 197a98a120 Properly handle paste exceptions
With Python 3, it doesn't work to decode type str. The str() recast
is still necessary however, since the exception data type is not
directly serializable in this way.

Change-Id: I3925cbb0d0ff594407c7b93b0d982f2cad386ad6
2021-08-13 17:07:34 +00:00
Ian Wienand 8057480ced diff parser : update next variable
In Python 3 this is a keyword, rename to nextline to avoid confusion

Change-Id: I46ebdeed3529587b21b3d17383331877e98c8d82
2021-08-04 11:34:31 +10:00
Ian Wienand 0a52b74bba diff parser: update calls to next()
The .next() syntax is broken and replaced with next() in Python3.
Update the calls in this file.

Change-Id: I026ed1888c54e3d71882940250c0532a60b40035
2021-08-04 11:26:06 +10:00
Ian Wienand a1e1667a36 Allow for overriding title
This simply adds a global template variable taken from
LODGEIT_TITLE_OVERRIDE that allows setting the site title for some
minimal customisation.

Previously, the opendev puppet would copy a custom layout.html over
the shipped version.  This allows us to simply set a variable and not
have duplicate copies of templates in config managment.

Change-Id: If25dcece0ecd2b7dfc0178c6886559ac2507b28f
2021-06-29 19:24:27 +10:00
Dmitriy Rabotyagov 2b0ca071f9 Add py3.8 support
Change-Id: I3d97ec43f84d00f8403a4ecf355a6d9b7c75d57e
2021-06-29 17:43:26 +10:00
Daniel Pawlik 7eb34a9d4f Fix issue related to new Pillow lib; change hash string encode
The captcha system may raise an error, when calculations were
float; added box argument for calling Pillow paste method.
This commit is also changing string encode in calculate_hash
function due "TypeError" exception.

Change-Id: Ibe175b78a8c446a7552c82732ec0ae25ef47c536
2021-04-28 16:39:01 +02:00
Zuul c6c6db6ca0 Merge "Add lodgeit-db script" 2021-02-01 21:58:28 +00:00
Zuul 97d0650334 Merge "Tuning pool_recycle to avoid MySQL server gone away" 2021-02-01 21:57:04 +00:00
Jeremy Stanley 69ec973e39 Skip deprecated lexers (Pygments 2.7.3 and later)
Work around the way Pygments maintainers have decided to list
"deprecated" lexers, but just skipping them if attempting to add
raises an IndexError because they look like JSONBareObject here:

https: //github.com/pygments/pygments/commit/5ee1754
Change-Id: Ia7b896263b4118ec369c5ce130addef3295a91a5
2021-02-01 20:14:51 +00:00
Jeremy Stanley 1970b75415 Use less ambiguous line iteration variable name
In diff.py the line iteration inline function relied on an iterable
named "l" (lower-case L) which is easily confused with the number 1
in some poorly-designed fonts. Because this is the only occurrence
for which newer pycodestyle is objecting, just go ahead and adjust
it rather than altering our style checks.

Also temporarily pin Pygments to deal which a regression which
arises in 2.7.3 and later.

Change-Id: I29cc8e5680d3fed3645b26f8b03d2ca299d974b0
2021-02-01 20:14:15 +00:00
Dmitriy Rabotyagov 5df6180484 Add lodgeit-db script
Adds script that makes operations (like pastes removal)
that are not secure to do via API without auth. It connects to DB and
interacts directly with DB.

Change-Id: I8ef65feda92387bf4dc548b8876fc9fb82dadc64
2020-03-30 17:31:33 +03:00
Igor Shishkin f53434f935 Tuning pool_recycle to avoid MySQL server gone away
Some time after lodgeit application have no load
SQLalchemy connection expires and application dies
with 5xx error and MySQL Server gone away exception.

By using a shorter default pool_recycle of 3600s which
can also be tweaked using environment variables, it allows
you to avoid dealing with this issue.

Change-Id: I79eb823458c604b2faff9bb1e9531c45fc1ed3cb
2020-03-18 08:27:14 -04:00
Mohammed Naser 54727daa85 Upload container images
This is an initial go at building this Python package and uploading
an image for it.  This will be followed up with some changes which
will make it easier to execute with an entrypoint and environment
variables later.

Change-Id: Ie2219fc96f32554bde1cac37faa0b961dc53b95e
2020-03-09 08:19:55 -04:00
Zuul 70d9a499d7 Merge "Removes unnecessary utf-8 encoding" 2020-03-06 01:49:51 +00:00
Zuul c37e845331 Merge "Fix python3 compatibility issue" 2020-03-05 20:12:49 +00:00
Iswarya_Vakati a1af412914 Removes unnecessary utf-8 encoding
This patches removes unnecessary utf-8 encoding

Change-Id: Ic4c35e70df0a1f3714c9a144c4b7fed9cd893aa2
2020-03-05 11:17:04 +00:00
David Pursehouse 1fa8df3fb2 Update URLs from openstack.org to opendev.org
Change-Id: Iee0f3f88d870a7b93c9d15624537680bbc181502
Signed-off-by: David Pursehouse <dpursehouse@collab.net>
2020-03-05 08:28:44 +09:00
Tristan Cacqueray 9b854e7729 Fix python3 compatibility issue
This change fix python3 compatibility:
* replace except obj, name with except obj as name
* use print function
* replace iteritems by six.iteritems
* replace xrange by range
* convert items() result to list

Change-Id: I70364e47541274d446c4449f820dce3e0b331b27
2020-03-04 13:09:24 -06:00
David Pursehouse 2d4b0ebee6 Fix pep8 errors
- E722 do not use bare 'except'

  Replace bare except clauses with explicit exception types.

- E741 ambiguous variable name 'l'

  Rename 'l' to 'locale'

In addition this patch squashes 684782 to use older
werkzeug version to not face with exceptions.

Generally this patch fixes lodgeit CI.

Also, add tox jobs to in-tree zuul config

These were defined in project-config, but we don't need to manage
that centrally.

Change-Id: Id750715472f88fa5dba0a2414fb1667df4a6dc40
Signed-off-by: David Pursehouse <dpursehouse@collab.net>
2020-03-04 13:09:04 -06:00
David Pursehouse af3168e449 Show the currently running version on the about page
The version is derived from the abbreviated sha1 of the current
head of the git repository.

Change-Id: Icc886596e500080cb014f9a17c3585a945516a98
2017-02-25 13:51:52 +09:00
David Pursehouse b19a482d47 Fix PEP-8 errors
There are several instances of the error:

   E305 expected 2 blank lines after class or function definition

Fix them all by adding the necessary blank lines.

Change-Id: I37e2990772f05a100fe303c1512b7bdfb10a660d
2017-02-25 13:47:11 +09:00
Jenkins 1cf655eb76 Merge "Remove extraneous trailing slashes from link URLs" 2016-04-12 16:24:29 +00:00
Jenkins c78a51c37c Merge "Update i18n files to remove unused translations" 2016-02-26 02:05:39 +00:00
Jenkins 87eb7d94f8 Merge "vim plugin: add vim plugin that targets openstack" 2016-02-26 02:01:06 +00:00
Jenkins d041a49339 Merge "Remove unused image file" 2016-02-22 06:50:34 +00:00
Tim Burke 1e07199441 Remove extraneous trailing slashes from link URLs
Previously, some links would have double slashes at the end, one from
url_for and one from the HTML template. This would cause a 404 if the
user attempted to follow the link.

Additionally, use url_for instead of manually building the link for the
unified diff.

Change-Id: Ic576c13c6785bd5ac47aa4095fb5e42dd774dc9e
2016-01-11 10:48:44 -08:00
David Pursehouse 60123815f5 Update i18n files to remove unused translations
Commit f413281 removed unused pagination code, but the i18n
files were not updated and thus the translation files still
contain a lot of strings that don't exist in the code any more.

Change-Id: Ibe85e86ac55628e01341d869e9871e97d7f8fac4
2015-12-17 16:40:56 +09:00
David Pursehouse a145e6392a Remove unused image file
Commit 0dc543a7 changed the background image used in the style
sheet, but did not remove the previous image that is now unused.

Change-Id: Iba306ab10fb9603fe8d41272dbca7cd56759cc9b
2015-12-17 16:31:34 +09:00
David Pursehouse 871f80a2ba Fix alert message shown when cookie is removed
Change-Id: Iad1b3e9ed3470bb633aacd775ba30627f52f5110
2015-12-16 18:03:53 +09:00
Antoni Segura Puimedon c25c93b3ce vim plugin: add vim plugin that targets openstack
http://paste.openstack.org/help/integration/ points to the original
vim plugin, which is obviously not using paste.openstack.org. I find
it worthy to keep the plugin in OSt infra with the necessary
modifications.

Change-Id: I435571a99a7ced2f958114238ea090054ac6797e
2015-12-02 17:15:08 +01:00
David Pursehouse 2acd8c9881 Replace XXX with TODO
Change-Id: I3f8af83d85a2a2b8d7c1e1723a5962e17938f8cd
2015-11-17 19:09:23 +09:00
David Pursehouse fbb61e9c1d Add tox configuration to enable PEP-8 checks, and fix various failures
- E126 continuation line over-indented for hanging indent
- E127 continuation line over-indented for visual indent
- E128 continuation line under-indented for visual indent
- E131 continuation line unaligned for hanging indent
- E265 block comment should start with '# '
- E272 multiple spaces before keyword
- E302 expected 2 blank lines, found <n>
- E712 comparison to False should be 'if cond is False:' or 'if not cond:'
- F401 '<name>' imported but unused

Change-Id: I2344cf2e8fd7910e72e9d8043423d25e43065ef2
2015-11-17 19:09:23 +09:00
Jenkins 0939be787c Merge "Security fix for possible private paste bruteforcing" 2015-11-17 10:04:31 +00:00
Jenkins 8c51991976 Merge "Fix header in help screen" 2015-10-13 06:21:05 +00:00
David Pursehouse 74237386ef Fix header in help screen
"Welcome in ..." is incorrect.  Change it to "Welcome to ...".

Change-Id: Iee68d22103395d8c196d17add6523be8ba8e01cd
2015-10-09 19:01:28 +02:00
David Pursehouse f41328156e Remove unused pagination lib
Change-Id: I018fa65ecdb550156ac52afb202ff6cb42771570
2015-10-09 02:18:18 +00:00
David Pursehouse c17e0a3741 Fix title on homepage
"Welcome On LodgeIt" is grammatically incorrect.

Change it to "Welcome To LodgeIt".

Change-Id: Id5614b0b84c566bd3a4a95ab1990bca113cf9595
2015-10-08 17:07:55 +09:00
Igor Shishkin 0ef0c909c3 Security fix for possible private paste bruteforcing
There was an ability to fetch private pastes by their numbers(paste_id)
which looks like security issue since could be used for bruteforcing.

Change-Id: I8e8bc9a05427a70b4203739e30a8fd8e532cfe96
Signed-off-by: Igor Shishkin <ishishkin@mirantis.com>
2015-08-28 12:03:58 +00:00
David Pursehouse 3e244a31fb Offer download of lodgeit.py with link to plain file on cgit
The current link is to the 'tree' version.  If the user right-clicks
and selects "save as", the file will be downloaded as an HTML file.

If the user clicks through to the tree page, another click is needed
on the "plain" link to either download the file with "save link as"
or to navigate to the plain link and then download.

Link directly to the "plain" page instead. This allows users to
directly download the file with "save link as".

Change-Id: I5d6a2f299ee264e5f06f68f72933a575b9042945
2015-08-24 11:20:01 +09:00
David Pursehouse d8a3fc1804 Remove out-of-date paragraph from the 'not found' page
Change-Id: I990ccc6d6a46e4c59e4b3771ff895657d7e162a6
2015-06-04 11:16:59 +09:00
David Pursehouse cd86bd9c2c Update i18n files
By running:

 make extract-messages update-translations compile-translations

Change-Id: If6e701f31c2ad2307f007fa226b736b289ccfbb9
2015-06-04 11:14:35 +09:00
Kun Huang 16c1c03b14 update 404 link of lodgeit.py
The old link of lodgeit.py is outdated(404 not found). This patch
replace it with git.openstack.org link as new one.

Change-Id: Ib12ed531e0811d94aa18d64e908717ff050ce743
2015-03-03 00:44:50 +08:00
Monty Taylor f739d002be Remove the all pastes listing.
The spammers kill things for all of us.

Change-Id: I37104005d24aa4a21d9dae770e4669e07666c7cb
2012-11-23 10:13:17 -08:00
Andrew Hutchings 3ce38e48ef Add missing files 2012-03-22 17:55:55 +00:00