Content-Security-Policy with wildcard - url

I'm trying to set the Content-Security-Policy and I'm not able to use a wildcard to match the second part of a URL (test).
Examples:
https://example.test1.com
https://example.test2.com
https://example.testN.com
I tried all the following combinations unsuccessfully:
https://example.*.com
https://example.*.
https://example.*
https://example*
I'll appreciate the help.
Thanks.

It is not supported, you can only have wildcards in the leftmost DNS label, see https://wiki.mozilla.org/Security/CSP/Specification#Hostname_Wildcards

Related

How can i trim URLs to root domain? i'm using notepad++

I have a list of domain name with parameters
http://www.anandinfra.net/project.php?id=2
http://artlinkinteriors.com/page.php?id=1
http://www.rabinmukherjeecollege.in/notice_details.php?id=1
I need to find other parts with domain and I have to replace those parts.
Finally my result should look as follows. Expected result:
http://www.anandinfra.net/
http://artlinkinteriors.com/
http://www.rabinmukherjeecollege.in/
How can I attain this result?
Hi you can create a CNAME in the DNS setting with the
http://www.anandinfra.net/project.php?id=2 pointing to http://www.anandinfra.net/
and same for the rest
In whatever programming language you use (which you don't disclose), find the relevant library handling URLs and use it to mutate them. DO NOT attempt to do that by string manipulation.

Deep Link Kit regex for zero or more

I am trying to use Deep Link Kit to route both of these paths:
myapp://page/2 // <- doesn't work
myapp://page/2/7 //<- works
The route handler I've registered at the moment is:
router.registerHandlerClass(AppRouteHandler.self, forRoute: "page/:number/:commentID(.*)")
I added the (.*) for the regex of zero or more comment IDs. However this doesn't seem to make any difference as it only works when you have both the :number and :commentID defined. I've also tried myapp://page/2/ but that doesn't work either. Any help would be appreciated.
UPDATE
One solution is to register the two routes separately:
router.registerHandlerClass(AppRouteHandler.self, forRoute: "page/:number")
router.registerHandlerClass(AppRouteHandler.self, forRoute: "page/:number/:commentID")
but ideally, I'd be able to use regex.
I counter this problem too, after combine you solution I came up with this solution
router.registerHandlerClass(AppRouteHandler.self, forRoute: "page/:number/?:commentID(.*)")
That will ignore the second /, and your commentID will be set with empty string

Can friendly-id gem work with capital letters in url e.g. /users/joe-blogs and /users/Joe-Blogs both work

I like the friendly id gem but one problem i'm seeing is when I type in a url with a capitol letter in it such as /users/Joe-Blogs it cant find the page. Its a little trivial but most sites can handle something like this and will generate the page whether it has a capitol letter or not. Does anyone know a fix for this?
Edit: to clarify this is for when users enter a url manually and put capitals in it just because its a name like author/Joe-Blogs. I've seen other sites handle this but rails seems to just give a 404.
friendly_id uses parameterize to create the slugs.
I think the best way to solve your problem is to parameterize the params before using it to find.
# controller
User.find(params[:id].parameterize)
Or parameterize the url where the link originated from.
As an addition to Vic's answer, you'll want to look at url normalization:
The following normalizations are described in RFC 3986 to result in equivalent URLs:
Converting the scheme and host to lower case.
The scheme and host components of the URL are case-insensitive. Most normalizers will convert them to lowercase.
Example: HTTP://www.Example.com/ → http://www.example.com/
In short - it's against convention to use capitalization in your urls.
You may also wish to look at URI normalize; more importantly, you should work to remove the capitalization from your URLs:
URI.parse(params[:id]).normalize

Amazon price in Google Spreadsheets

I tried following the answers gave here, but I get the error Imported Xml content can not be parsed.
Here's what I tried:
=importXml("http://www.amazon.it/Asus-GeForce-Scheda-Display-Edition/dp/B00SKWIISQ/","//span[#id='priceblock_ourprice']")
=importxml(hyperlink(concatenate("http://www.amazon.it/Asus-GeForce-Scheda-Display-Edition/dp/B00SKWIISQ/")),"//*[#id='priceblock_ourprice']")
None of them worked..
EDIT: The functions are intermittently working. Seems there's an issue specifically with the Amazon site as sometimes this works, sometimes it doesn't (and I get "imported content cannot be parsed"). When it doesn't, sometimes if I add or remove the trailing slash it works again. No problem with other sites. Seems a known issue: https://productforums.google.com/forum/#!topic/docs/UuMGRl7Asew https://productforums.google.com/forum/#!topic/docs/yWPaNDK0Kpg
What's a mistery is the cause.
if you try //* xPath, then you'll see that Amazon is making a robot check. That is the reason of unsuccessful parsing.
Unfortunately, I can't see the obvious way to overcome this.
And, as to changing comma to semicolon and vice versa - it doesn't work, because it depends on your local settings for Google Spreadheet, which delimiter you have to use in functions. For some countries it's a comma, for others it's a semicolon.
Try this:
=importXml("http://www.amazon.it/Asus-GeForce-Scheda-Display-Edition/dp/B00SKWIISQ";"//span[#id='priceblock_ourprice']")
I changed the colon to semicolon and removed the trailing slash of the URL to make sure that no HTTP redirects are done.

Wilcard in url patterns Yii Framework

I'm trying to create a dynamic url pattern for the following url:
http://domain.com/content/pagetitle
This is what I have added in the url.rules:
'content/<page:.*?>' => 'cms/default/home',
this works fine for /content/pagetitle.html but not for /content/pagetitle while my url suffix is empty. Does anyone know what I'm doing wrong?
Your problem might also be that the regex "any character" character . gets escape if outside of a named group.
<controller:[a-zA-Z]>/(.*)
turns into
<controller:[a-zA-Z]>/(\.*)
// ^ It escaped it for us even though we didn't want it
The solution is simply to make group for it:
<controller:[a-zA-Z]>/<wildcard:.*>
Not sure why you are adding the .*? there...
The following example should work
'content/<page:.+>' => 'cms/default/home',
You do not need a wildcard in this case:
'content/<page>' => 'cms/default/home',

Resources