forked from MarseyWorld/MarseyWorld
parent
7a682d95c6
commit
25e594d673
|
@ -764,6 +764,35 @@ def submit_post(v, sub=None):
|
|||
parsed_url = urlparse(url)
|
||||
|
||||
domain = parsed_url.netloc
|
||||
if domain in ('old.reddit.com','twitter.com','instagram.com','tiktok.com') and '/search' not in url:
|
||||
new_url = ParseResult(scheme="https",
|
||||
netloc=parsed_url.netloc,
|
||||
path=parsed_url.path,
|
||||
params=parsed_url.params,
|
||||
query=None,
|
||||
fragment=parsed_url.fragment)
|
||||
else:
|
||||
qd = parse_qs(parsed_url.query)
|
||||
filtered = {k: val for k, val in qd.items() if not k.startswith('utm_') and not k.startswith('ref_')}
|
||||
|
||||
new_url = ParseResult(scheme="https",
|
||||
netloc=parsed_url.netloc,
|
||||
path=parsed_url.path,
|
||||
params=parsed_url.params,
|
||||
query=urlencode(filtered, doseq=True),
|
||||
fragment=parsed_url.fragment)
|
||||
|
||||
url = urlunparse(new_url)
|
||||
|
||||
if url.endswith('/'): url = url[:-1]
|
||||
|
||||
search_url = url.replace('%', '').replace('\\', '').replace('_', '\_').strip()
|
||||
repost = g.db.query(Submission).filter(
|
||||
Submission.url.ilike(search_url),
|
||||
Submission.deleted_utc == 0,
|
||||
Submission.is_banned == False
|
||||
).first()
|
||||
if repost and SITE != 'localhost': return redirect(repost.permalink)
|
||||
|
||||
domain_obj = get_domain(domain)
|
||||
if not domain_obj: domain_obj = get_domain(domain+parsed_url.path)
|
||||
|
|
|
@ -107,9 +107,7 @@
|
|||
<div id="urlblock">
|
||||
<label for="URL" class="mt-3">URL</label>
|
||||
<input autocomplete="off" class="form-control" id="post-url" aria-describedby="URLHelp" name="url" type="url" placeholder="Optional if you have text." value="{{request.values.get('url','')}}" required oninput="checkForRequired();hide_image();savetext();checkRepost(){% if SITE_NAME != 'PCM' %};autoSuggestTitle(){% endif %}">
|
||||
<p id="system" class="form-text text-muted">
|
||||
To post an image, use a direct image link such as i.imgur.com
|
||||
</p>
|
||||
<small id="system" class="form-text text-muted">To post an image, use a direct image link such as i.imgur.com</small>
|
||||
</div>
|
||||
<div id="image-upload-block">
|
||||
<div><label class="mt-3">Attachment Upload</label></div>
|
||||
|
|
Loading…
Reference in New Issue