douhe6181 2014-01-10 07:29
浏览 90
已采纳

将html <a>放入mysql表文本字段 - url注入?

This is an awkward question but I am helping edit a site and there are some text fields in the MySQL table that I wanted to edit. One of the edits I wanted to do was add a hyperlink.

So I went ahead and put in <a href = " etc. etc." </a>. When I save it and view the website, the website injects the site's URL before my link breaking the link.

e.g. I am working www.example.com trying to insert a hyperlink to www.google.ca

It will output as www.example.com/www.google.ca instead of www.google.ca

I am pretty new to PHP/MySQL so I'm not sure if this is common or what is causing this. I tried looking at the file itself and the css to see if there was something causing this. I am not sure if this is even a normal thing or if there is a workaround it that I'm unaware of.

If anybody has ideas on where I should look (if they suspect it's the site that's injecting it), please let me know.

  • 写回答

1条回答 默认 最新

  • duanpin2034 2014-01-10 07:35
    关注

    As I mentioned in the comments above already:

    <a href="www.google.ca">Google</a>
    

    is a relative url and will output as http://yoursite.tld/www.google.ca

    <a href="http://www.google.ca">Google</a>
    

    will output as a correct link.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用