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

  • SEARCH
  • Home
  • 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 6675507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:51:54+00:00 2026-05-26T03:51:54+00:00

I have following config in my antisamy policy file: Old YouTube Object: <object width=1280

  • 0

I have following config in my antisamy policy file:

Old YouTube Object:

<object width="1280" height="720">
<param 
    name="movie" 
    value="http://www.youtube.com/v/Hl-zzrqQoSE
           ?version=3
           &amp;hl=en_US
           &amp;rel=0">
</param>
<param name="allowFullScreen" value="true">
</param>
<param name="allowscriptaccess" value="always">
</param>
<embed src="http://www.youtube.com/v/Hl-zzrqQoSE
            ?version=3
            &amp;hl=en_US
            &amp;rel=0" 
       type="application/x-shockwave-flash" 
       width="1280" 
       height="720" 
       allowscriptaccess="always" 
       allowfullscreen="true">
 </embed>
 </object>

The AntiSamy config:

 <common-regexps>
     <regexp name="YouTubeURL" value="(\s)*(http(s?)://)www.youtube.com/v/[\p{L}\p{N}]+[\p{L}\p{N}\p{Zs}\.\#@\$%\+&amp;;:\-_~,\?=/!]*(\s)*"/>
 ....

<!-- Tags related to YouTube -->
<tag name="object" action="validate">
<attribute name="height"/>
<attribute name="width"/>
<attribute name="type">
    <literal-list>
        <literal value="application/x-shockwave-flash"/>
    </literal-list>
</attribute>
<attribute name="data">
    <regexp-list>
        <regexp name="YouTubeURL"/>
    </regexp-list>
</attribute>
</tag>
<tag name="embed" action="validate">
<attribute name="height"/>
<attribute name="width"/>
<attribute name="type">
    <literal-list>
        <literal value="application/x-shockwave-flash"/>
    </literal-list>
</attribute>
<attribute name="allowfullscreen">
    <regexp-list>
        <regexp name="boolean"/>
    </regexp-list>
</attribute>
<attribute name="allowscriptaccess">
    <literal-list>
        <literal value="always"/>
    </literal-list>
</attribute>
<attribute name="src">
    <regexp-list>
        <regexp name="YouTubeURL"/>
    </regexp-list>
</attribute>
<attribute name="movie">
    <regexp-list>
        <regexp name="YouTubeURL"/>
    </regexp-list>
</attribute>
</tag>

Currently my config on iframe:

    <!-- Frame & related tags -->

    <tag name="iframe" action="remove"/>
    <tag name="frameset" action="remove"/>
    <tag name="frame" action="remove"/>

The new YouTube iframe:

<iframe 
    width="1280" 
    height="720" 
    <!--   src="https://www.youtube-nocookie.com/embed/Hl-zzrqQoSE"  -->
    src="https://www.youtube.com/embed/Hl-zzrqQoSE" 
    frameborder="0" 
    allowfullscreen>
</iframe>

I figure the code for iframe should like this:

<tag name="iframe" action="validate">
        <attribute name="height"/>
        <attribute name="width"/>
        <attribute name="frameborder"/>
        <attribute name="src">
            <regexp-list>
                <regexp name="YouTubeURL"/>
            </regexp-list>
        </attribute>

        <attribute name="allowfullscreen">
            <regexp-list>
                <regexp name="boolean"/>
            </regexp-list>
        </attribute>
</tag>

How do you change the regex so it will accept the old and new links like:

    https://www.youtube-nocookie.com/embed/Hl-zzrqQoSE
    
    
    http://www.youtube-nocookie.com/v/Hl-zzrqQoSE?version=3&hl=en_US&rel=0
    http://www.youtube.com/v/Hl-zzrqQoSE?version=3&amp;hl=en_US&amp;rel=0"
  • 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-05-26T03:51:54+00:00Added an answer on May 26, 2026 at 3:51 am
    \s*(https?://)www.youtube(-nocookie)?.com/(?:v|embed)/[\p{L}\p{N}]+[\p{L}\p{N}\p{Zs}.#@$%+&;:_~,?=!/-]*\s*
    

    I took the liberty to remove unnecessary capture groups, escapes and characters.

    Although I personally would use something like:

    \s*(https?://www.youtube(?:-nocookie)?.com/(?:v|embed)/([a-zA-Z0-9-]+).*)
    

    That puts the entire youtube URL in match group 0 and the video id in match group 1.
    Also it doesn’t make a whole lot of sense to use unicode properties when youtube’s URLs don’t contain unicode characters.

    Demo: http://rubular.com/r/jv4zO9ys2L

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

Sidebar

Related Questions

I have the following text in xml file: <Config Builder=LP Wizard> <Libraries> <Library Name=XCAMSource/>
I have the following config file: <system.diagnostics> <trace autoflush=true indentsize=1 > <listeners> <add name=dbgTrace
I have the following config file for solr: <requestHandler name=/update/extract startup=lazy class=solr.extraction.ExtractingRequestHandler > <lst
let's say I have the following config file [branch master] remote = origin merge
I have the following file Log4net.config in my bin directory: <?xml version=1.0 encoding=utf-8 ?>
I have following in my config.php file for one of my web app. //db
If have the following web.config : <configuration> <system.web> <authentication mode=Forms> <forms name=MembershipCookie loginUrl=Login.aspx protection=All
I have the following config for persistence.xml file: <?xml version=1.0 encoding=UTF-8?> <persistence xmlns=http://java.sun.com/xml/ns/persistence xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
I have the following in my config/routes.php file: $route['(:any)'] = dashboard/index/$1; This works as
I have the following config for my binding: <binding name=wshttp openTimeout=00:01:00 sendTimeout=00:02:00 receiveTimeout=00:03:00 closeTimeout=00:04:00>

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.