mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	spa: escape double quotes
This commit is contained in:
		
							parent
							
								
									63a3811aa7
								
							
						
					
					
						commit
						6a21909281
					
				
					 2 changed files with 5 additions and 2 deletions
				
			
		| 
						 | 
					@ -346,6 +346,9 @@ static inline int spa_json_encode_string(char *str, int size, const char *val)
 | 
				
			||||||
		case '\f':
 | 
							case '\f':
 | 
				
			||||||
			__PUT('\\'); __PUT('f');
 | 
								__PUT('\\'); __PUT('f');
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
							case '"':
 | 
				
			||||||
 | 
								__PUT('\\'); __PUT('"');
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
			__PUT(*val);
 | 
								__PUT(*val);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -160,8 +160,8 @@ static void test_encode(void)
 | 
				
			||||||
	spa_assert(strncmp(dst4, "\"tes", 4) == 0);
 | 
						spa_assert(strncmp(dst4, "\"tes", 4) == 0);
 | 
				
			||||||
	spa_assert(spa_json_encode_string(dst6, sizeof(dst6), "test") == 6);
 | 
						spa_assert(spa_json_encode_string(dst6, sizeof(dst6), "test") == 6);
 | 
				
			||||||
	spa_assert(strncmp(dst6, "\"test\"", 6) == 0);
 | 
						spa_assert(strncmp(dst6, "\"test\"", 6) == 0);
 | 
				
			||||||
	spa_assert(spa_json_encode_string(dst, sizeof(dst), "test\"\n\r \t\b\f\'") == 19);
 | 
						spa_assert(spa_json_encode_string(dst, sizeof(dst), "test\"\n\r \t\b\f\'") == 20);
 | 
				
			||||||
	spa_assert(strcmp(dst, "\"test\"\\n\\r \\t\\b\\f'\"") == 0);
 | 
						spa_assert(strcmp(dst, "\"test\\\"\\n\\r \\t\\b\\f'\"") == 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char *argv[])
 | 
					int main(int argc, char *argv[])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue