If a flight from Los Angeles to San Francisco (both in legal California, over one hundred miles from any land that is not California) is diverted to Kansas City, we've got bigger problems than someone carrying a few joints in their luggage.
The aircraft could end up landing at one of several Air Force bases along the way, where it definitely is illegal. But I cannot imagine the legal process whereby someone is actually charged for possession because their flight had an emergency landing still within the state of California. The court would have to be a military court, and I don't know the process by which a civilian would end up tried in a court that has jurisdiction over an AF base. The court matters because the DA and prosecutor decide who to charge.
I don't believe civilians can be sent to a court martial in general (although I could certainly be wrong). The few times I was aware that a civilian got in trouble on post, the local police come pick up the civilian (if they need to be held) and it's tried in a civilian court.