A very close friend of mine is a landscape photograper and artist. He was thrown in jail, and acused of being a spy in Iran for being too close to a boarder in the northern part of the country. Allthough it's illegial, he checked with the boarder patroll in the region and asked if it was okay to take photos in that area beforehand. They said as long as he was xy kilometers from the border it was okay. He obeyed and kept his distance. Then he was arrested the next day.
It wasn't fun for him to be in jail there and he had no access to a lawyer, no translating was done for him and he had no idea what would hapen until, after a month, he was simply let go. He was lucky.
It's a good idea to obay the laws (to the letter) in any foreign country, but especially countries that are not known for their disregard for human rights.