Stopgap to avoid excessively long string values (backport)

Change-Id: I9b20d0d4bad5f68cd0cc440ee1995193ecec9abd
trim incoming string values

Change-Id: I0055dddbb0b810432879d275e1e102069e7736c2