Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-1094

Meta tags should not be used to refresh or redirect

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Remove this meta refresh tag.
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way
    • Legacy Key:
      MetaRefreshCheck
    • Covered Languages:
      HTML
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      20min

      Description

      Use of <meta http-equiv="refresh"> is discouraged by the World Wide Web Consortium (W3C).
      If a user clicks the 'Back' button, some browers will go back to the redirecting page, which will prevent the user from actually going back.

      To refresh the page, a better alternative is to use Ajax, to refresh only what needs to be refreshed and not the whole page.
      To redirect to another page, using the HTTP response status code 301 'Moved Permanently' and 302 'Found' is a better option.

      Noncompliant Code Example

      <head>
        <meta http-equiv="refresh" content="5">   <!-- Non-Compliant -->
        <meta name="description" content="..."> 
      </head>
      

      Compliant Solution

      <head>
        <meta name="description" content="..."> 
      </head>
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            freddy.mallet Freddy Mallet (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: