@@ -5451,6 +5451,7 @@ def setup_kvec_input(k_vec, k_vec_dict, isocif_cif):
54515451 return
54525452 import tempfile
54535453 import re
5454+ import urllib.parse
54545455 from GSASII.exports import G2export_CIF
54555456 from . import ISODISTORT as ISO
54565457 isoformsite = 'https://iso.byu.edu/isodistortform.php'
@@ -5668,10 +5669,21 @@ def setup_kvec_input(k_vec, k_vec_dict, isocif_cif):
56685669 data["irrep1"] = irrep1
56695670 data["irrpointer1"] = irrpointer1
56705671
5671- r_pattern = r'<input\s+type=["\']?radio["\']?\s+name=["\']?'
5672- r_pattern += r'orderparam["\']?\s+value=["\']?([^"\']+)["\']?'
5672+ # Use attribute-aware patterns to correctly capture values that may
5673+ # contain single quotes (e.g. magnetic space groups like P4_1'2_12').
5674+ # The original [^"\'"]+ pattern stopped at ' in the value; instead
5675+ # we match the closing delimiter explicitly so ' is allowed inside
5676+ # double-quoted attributes and " inside single-quoted ones.
5677+ r_pattern = (
5678+ r'<input\s+type=["\']?radio["\']?\s+name=["\']?'
5679+ r'orderparam["\']?\s+value=(?:"([^"]*)"' + r"|'([^']*)')"
5680+ )
56735681 radio_val_pattern = re.compile(r_pattern, re.IGNORECASE)
5674- radio_vals = radio_val_pattern.findall(out4)
5682+ # findall returns (dq_match, sq_match) tuples; take whichever is non-empty
5683+ radio_vals = [
5684+ dq if dq else sq
5685+ for dq, sq in radio_val_pattern.findall(out4)
5686+ ]
56755687 cleaned_radio_vals = [value.strip() for value in radio_vals]
56765688 iso_fn = _get_opt_val('isofilename', out4).strip()
56775689 data["isofilename"] = iso_fn
@@ -5680,7 +5692,7 @@ def setup_kvec_input(k_vec, k_vec_dict, isocif_cif):
56805692 print("Processing mode:", radio_val)
56815693 data["input"] = "distort"
56825694 data["origintype"] = "method2"
5683- data["orderparam"] = radio_val + '" CHECKED'
5695+ data["orderparam"] = radio_val
56845696 out5 = requests.post(isoformsite, data=data).text
56855697
56865698 out_cif = ISO.GetISOcif(out5, 2, mag=mag)
0 commit comments