Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8900547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:07:24+00:00 2026-06-15T01:07:24+00:00

I’m working on a drupal 7 install where arg(x) http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/arg/7 has been used in

  • 0

I’m working on a drupal 7 install where arg(x)

http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/arg/7

has been used in html output a lot, in view templates and other places etc. Although I’ve looked at the documentation and searched around on this topic, I’m still confused as to if I need to sanitize/escape the output of arg(x) with php’s htmlspecialchars or drupal’s check_plain etc to prevent xss.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:07:26+00:00Added an answer on June 15, 2026 at 1:07 am

    Technically, as per my test, you do need to escape it.
    But the good side is that, arg() does not use the direct user input always.

    If the URL (or more precisely, $_GET['q']) is node/<h3>/edit, arg(1) returns <h3> without a check plain.
    If you want to test it yourself, add the snippet below and see yourself.

    <?php
    echo (arg(1, 'node/<h3>/edit')); ?>Normal text 
    

    You will now see “Normal text” in h3.

    If a node has ID 4, when viewing the node, $_GET['q'] would be node/4. If the path is not aliased, URL would be the same.
    as per the example above, if the user opened node/<h3>, arg(1) would be <h3> without escaping but there is a doubt that will user sees your snippet that you used arg() because that page returns a 404 result (where you don’t see any blocks, page content, etc).

    Using arg() in t(), url() , l() and other functions will always escape/sanitize the result so in practical world, it’s unlikely that you’ll find a real case that someone can XSS your site.

    Here is a bad use that I can think about.
    In page.tpl.php file, you could add a class from the URL path like this:

    <body class="<?php print arg(0); ?>">
    

    You could expect that on node pages, you will see body tag’s class is “node”, and on admin pages, class is “admin”. But imagine the user opens a page like this:

    http://example.com/" onclick="alert('You are clicking on me');"
    

    So the actual HTML of the body tag would be like this:

    <body class="" onclick="alert('You are clicking on me');">
    

    Now you will see that the body tag has an empty class attribute, and the body also has an onclick event added. This could be the worst example you can see – but I just wanted to show you some real example.
    Using $node->nid is safe though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.