dqdpz60048 2017-07-23 16:14
浏览 224
已采纳

如果URL作为输入参数提交,则Apache会阻止请求

I have been searching on internet, but suprisingly not even single answer or single query has been raised by anyone, am I the only one facing this issue. May be because when we say URL in form google gives all the results related 'attribute' of form. But here I am not talking about action URL at all. so i will start with html code.

 <form action="/something_that_does_not_matter" method=post>
    <input name="profile" type="text" placeholder="Enter name"/>
<input name="link" type="text" placeholder"="Enter URL"/>
</form>

This form works fine if user submits some strings in both inputs. When it becomes issue? When you enter any url in link field. because that is what is supposed to do. Please do not ask me to tell script here, because I am 100% sure theres no issue on server side, as i have even tried with simplest php like

<?php echo $_POST["link"]; ?>

It happens on certifiedhosting server only, on my local it works fine, little bit guessing and research gave me this one reason, that apache has this security protocol which if enabled wont let you, submit something harmful. And it is blocking my any url, even if is submit "http://hey" it gets blocked so issue is not with url also.

My Hosting provider is ready to disable that rule for me, but then it would be my own risk. so I dont want that obviously.

So now my question is why is security there, and if it is really threat, how do someone who really wants genuinely to do it will do it?

For pure html form submission i cannot find solution at all. But for ajax based request i have found some solutions. First i tried to encode/decode which wont work, as server first tries to find that encoded subsrtring which has http:// in it. So no use

Another solution is to submit ht$$p:// and then fix it in my php script. but its all workaround, and forces me to use Ajax based. what if just want to do it in HTML form, my application wont have JavaScript on it.

Anyone?

  • 写回答

2条回答 默认 最新

  • drqvsx1228 2017-07-26 11:50
    关注

    No sure about how to do it without javascript, but you can strip out 'http:' from url using javascript and submit it it will work, and as we all know, // anyway will tell you starting of url.

    Making changes to code by @Aayaush

    <input type="text" placeholder="Enter URL" onkeyup="document.getElementById('link').value=(this.value).replace(/https?:/,'')" >
    
    <form>
    <input name="profile" type="text" placeholder="Enter name"/>
    <input name="link" id='link' type="hidden">
    <input type="submit">
    </form>
    

    Also check this. https://stackoverflow.com/a/39375297/3335776

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀