My turn to ask a question: For local development I...
# box-products
m
My turn to ask a question: For local development I am utilizing CommandBox and Adobe (or Lucee either one have the same result...) To simplify I have a single page index.cfm that i am going to load via a few different mechanisms My gut is this is a side effect of undertow but when a .cfm is in the path after the executing file the rest of the path is dropped index.cfm
Copy code
<cfdump var="#[CGI.PATH_INFO, CGI.SCRIPT_NAME]#">
CGI.PATH_INFO ADDRESS index.cfm/test/test LUCEE CommandBox /test/test ADOBE CommandBox /test/test ADOBE IIS /test/test ADDRESS index.cfm/test.cfm/test/test LUCEE CommandBox /test.cfm ADOBE CommandBox /test.cfm ADOBE IIS /test.cfm/test/test ADDRESS index.cfm/test.Cfm/test/test LUCEE CommandBox /test.Cfm/test/test ADOBE CommandBox /test.Cfm/test/test ADOBE IIS /test.Cfm/test/test
p
Likely you have the URL rewrite enabled in your Commandbox
server.json
. That’s a default setup if you’re not careful…
b
@Michael Schmidt I'm not 100% clear on your test
Are the values next to each web server, the script name, path info, or both?
Also, is there a particular one you're asking about?
You put a bunch of information here, but what exactly is the question?
m
I am sorry for not being clear I tried doing a mark down table with that data... but that just didn't work. The address is where I would navigate to and the value is the value of path_info. I will go and check to see if disabling rewrite helps. Thank you
In the real world i have an old CMS system that was created a long time ago. inside of the CMS I have the ability to have custom apps inside of those custom Apps they could have additional pages lets say

https://example.com/custom.cfm/frontPage/images.cfm/PrettyPicture.jpg

So this loads inside the CMS the frontPage custom app and then uses the images.cfm inside of the customApp to then serve back PrettyPicture.jpg To figure out the stuff in the URI after custom.cfm we would use CGI.PATH_INFO which would contain /frontPage/images.cfm/PrettyPicture.jpg But under commandbox which I am using to spin up folks local development environment CGI.PATH_INFO in this scenario becomes /frontPage/images.cfm and it drops everything after cfm The recreation steps above in the original post were just to eliminate any need for explanation of the architecture and bring it down to a basic demo and test case.
And disabling the rewrite didn't have any effect.. I dsiabled in server.json with
Copy code
{
  "app": {
    "cfengine": "adobe@2018"
  },
  "web": {
    "rewrites": {
      "enable": false
    }
  }
}
Copy code
Values of CGI.PATH_INFO
+------------------------------+--------------------------+--------------------------+---------------------+
| Address                      | Result Lucee Command Box | Result Adobe Command Box | Result Adobe IIS    |
+------------------------------+--------------------------+--------------------------+---------------------+
| index.cfm/test/test          | /test/test               | /test/test               | /test/test          |
| index.cfm/test.cfm/test/test | /test.cfm                | /test.cfm                | /test.cfm/test/test |
| index.cfm/test.Cfm/test/test | /test.Cfm/test/test      | /test.Cfm/test/test      | test.Cfm/test/test  |
+------------------------------+--------------------------+--------------------------+---------------------+
b
@Michael Schmidt Thanks for clarifying, that's where I thought you were going, but wanted to make sure
rewrite will have nothing to do with this. Rewrites are for when you want to have
Copy code
<http://site.com/foo/bar|site.com/foo/bar>
in the browser but have it rewritten to
Copy code
<http://site.com/index.com/foo/bar|site.com/index.com/foo/bar>
on the backend
This has to do with the servlet mappings configured in the web.xml
Most
web.xml
files have servlet mappings like this in them
Copy code
index.cfm/*
which is how they match stuff after the file.
Adobe historically has supported a servlet mapping path of
Copy code
*.cfm/*
which matches any file name in any folder with anything after it, but this does NOT meet the servlet spec. Only Macromedia JRun and Adobne's hacked up version of Tomcat supports this.
As a result, CommandBox has its own magic up its sleeve in the form of a servlet filter that applies a regular expression to match these requests, pull out the path info, and modify the request so it will match the servlet filters.
Also note, servlet filter paths are also case sensitive (at least in non-JRun and non-hacked-up-Adobe-Tomcat servlets) which is prolly why you see varying behavior when you upper case a letter in the
.cfm
part to
.cFm
So, after all that explanation, the short answer is your use case is simply one I'd never seen and never considered! 🙂
And the issue is that the regex is "greedy" in that the
.+
portion matches as much as possible so it matches all the way to the last
.cfm
it finds!
👍 1
I honestly had never thought about a URL such as
Copy code
/foo.cfm/brad.cfm/wood
so I had never tested it!
We can easily modify this regex to match what Adobe does
m
yeah that is what i had thought (the greediness of a regex) ...
i wouldn't have thought of it that way in the last 12 years but 18 years ago when the CMS was written this was a cheapway to make SEF URLs and also then have an application framework for this CMS
b
You may notice the source code of this filter (which we bundle in CommandBox) allows the regex to be customized. While we don't expose this as a first class setting (because I've never needed to change it), it is possible in theory to turn off the default use of the filter and then provide a web.xml override that includes the servlet filter but with your own custom init-param
m
i would be willing to try that out... it was just a oh my gosh moment when telling folks oh this is an amazing way to run your servers locally without any admin access needed to a computer. And then it was like oh i guess it doesn't work with all scenarios
b
It appears changing the regex to
Copy code
^(/.+?\.cf[cm])(/.*)
has the desired affect
lol, well congrats, you've found something no one else has tried in the 7 or so years CommandBox has existed 🙂
But we will fix this for sure 🙂
👍 1
I'm about to head to dinner-- I'm on Germany time today as I've arrived for CFCamp in Munich this morning but I'll test out a work around when I can
m
Thank you i appreciate it
b
Ok, sad news-- I put together an example of disabling the regexpathintofilter with default settings and re-adding it with a web.xml override and a modified regular expression, but I found a bug in CommandBox which prevents servlet filters from getting loaded from web.xml overrides! So, the bad news is there isn't a work around for you on the current version of CommandBox, but the good news is I'll fix this for the next version of CommandBox.
Also note, the
.cfm
matching is case sensitive mostly because the servlet filter is also case sensitive meaning the first occurrence of
*.cfm/
in the path does need to be lowercase for CF to process it. And while it is possible to add upper case servlet mappings to a custom
web.xml
, that's not common to see and Adobe doesn't ship their web.xml like that out of the box.
m
honestly the mix case was just a cheap way for me to get the folks up and running
b
The corrected regex is committed and built on the bleeding edge builds of CommandBox 6.0.0
m
Thank you @bdw429s validated it works correctly with alpha commandbox 6
👍 1