Merge pull request #12 from InvoxiPlayGames/patch-1
Place limits on star count to avoid removing stars
This commit is contained in:
1 file changed
+7
-2
@@ -87,11 +87,16 @@ class CreatorIDFileResource(resource.Resource):
|
|||||||
#bad formatting
|
#bad formatting
|
||||||
if "x-hatena-star-count" not in headers:
|
if "x-hatena-star-count" not in headers:
|
||||||
ServerLog.write("%s got 403 when requesting %s without a X-Hatena-Star-Count header" % (request.getClientIP(), path), Silent)
|
ServerLog.write("%s got 403 when requesting %s without a X-Hatena-Star-Count header" % (request.getClientIP(), path), Silent)
|
||||||
request.setResponseCode(400)
|
request.setResponseCode(403)
|
||||||
return "400 - Denied access\nRequest lacks a X-Hatena-Star-Count http header"
|
return "403 - Denied access\nRequest lacks a X-Hatena-Star-Count http header"
|
||||||
|
|
||||||
#add the stars:
|
#add the stars:
|
||||||
amount = int(headers["x-hatena-star-count"])
|
amount = int(headers["x-hatena-star-count"])
|
||||||
|
if (amount < 1) or (amount > 65535):
|
||||||
|
ServerLog.write("%s got 403 when requesting %s with an invalid X-Hatena-Star-Count header" % (request.getClientIP(), path), Silent)
|
||||||
|
request.setResponseCode(403)
|
||||||
|
return "403 - Denied access\nRequest has an invalid X-Hatena-Star-Count http header"
|
||||||
|
|
||||||
if not Database.AddStar(creator, file[:-5], amount):
|
if not Database.AddStar(creator, file[:-5], amount):
|
||||||
#error
|
#error
|
||||||
ServerLog.write("%s got 500 when requesting %s" % (request.getClientIP(), path), Silent)
|
ServerLog.write("%s got 500 when requesting %s" % (request.getClientIP(), path), Silent)
|
||||||
|
|||||||
Reference in new issue
Block a user
