input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code public List<Pair<String, Integer>> getColumns(String schema, String table) throws SQLException { if (!columnsCache.isEmpty()){ return columnsCache; } DbmsQueryResult queryResult = connection.executeQuery(syntax.getColumnsCommand(schema, table)); Jdbc...
#fixed code public List<Pair<String, Integer>> getColumns(String schema, String table) throws SQLException { if (!columnsCache.isEmpty()){ return columnsCache; } columnsCache.addAll(connection.getColumns(schema, table)); return columnsCache; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void print(int indentSpace) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < indentSpace; i++) { builder.append(" "); } builder.append(this.toString()); System.out.println(builder.toString()); for (QueryExecutionNode de...
#fixed code void addParent(QueryExecutionNode parent) { parents.add(parent); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public List<String> getTables(String schema) throws SQLException { if (!tablesCache.isEmpty()){ return tablesCache; } DbmsQueryResult queryResult = connection.executeQuery(syntax.getTableCommand(schema)); JdbcResultSet jdbcQueryResult = new JdbcResul...
#fixed code public List<String> getTables(String schema) throws SQLException { if (!tablesCache.isEmpty()){ return tablesCache; } tablesCache.addAll(connection.getTables(schema)); return tablesCache; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<String> getPartitionColumns(String schema, String table) throws VerdictDBDbmsException { List<String> partition = new ArrayList<>(); DbmsQueryResult queryResult = execute(syntax.getPartitionCommand(schema, table)); JdbcResultSet jdbcRes...
#fixed code @Override public List<String> getPartitionColumns(String schema, String table) throws VerdictDBDbmsException { List<String> partition = new ArrayList<>(); DbmsQueryResult queryResult = execute(syntax.getPartitionCommand(schema, table)); while (queryResult.next()) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testConvertFlatToProgressiveAgg() throws VerdictDBValueException { SelectQuery aggQuery = SelectQuery.create( ColumnOp.count(), new BaseTable("myschema", "mytable", "t")); AggExecutionNode aggnode = AggExecutionNode.create(aggQu...
#fixed code @Test public void testConvertFlatToProgressiveAgg() throws VerdictDBValueException { SelectQuery aggQuery = SelectQuery.create( new AliasedColumn(ColumnOp.count(), "agg"), new BaseTable(newSchema, newTable, "t")); AggExecutionNode aggnode = AggExecutio...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public ExactRelation rewriteWithSubsampledErrorBounds() { // if this is not an approximate relation effectively, we don't need any special rewriting. if (!doesIncludeSample()) { return getOriginalRelation(); } ...
#fixed code @Override public ExactRelation rewriteWithSubsampledErrorBounds() { // if this is not an approximate relation effectively, we don't need any special rewriting. if (!doesIncludeSample()) { return getOriginalRelation(); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<String> getTables(String schema) throws VerdictDBDbmsException { List<String> tables = new ArrayList<>(); DbmsQueryResult queryResult = execute(syntax.getTableCommand(schema)); JdbcResultSet jdbcResultSet = new JdbcResultSet(queryResult...
#fixed code @Override public List<String> getTables(String schema) throws VerdictDBDbmsException { List<String> tables = new ArrayList<>(); DbmsQueryResult queryResult = execute(syntax.getTableCommand(schema)); while (queryResult.next()) { tables.add((String) queryResul...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public List<Pair<String, Integer>> getColumns(String schema, String table) throws SQLException { if (!columnsCache.isEmpty()){ return columnsCache; } DbmsQueryResult queryResult = connection.executeQuery(syntax.getColumnsCommand(schema, table)); Jdbc...
#fixed code public List<Pair<String, Integer>> getColumns(String schema, String table) throws SQLException { if (!columnsCache.isEmpty()){ return columnsCache; } columnsCache.addAll(connection.getColumns(schema, table)); return columnsCache; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testExecuteNode() throws VerdictDBException { BaseTable base = new BaseTable(originalSchema, originalTable, "t"); SelectQuery query = SelectQuery.create(Arrays.<SelectItem>asList(new AsteriskColumn()), base); QueryExecutionNode root = Creat...
#fixed code @Test public void testExecuteNode() throws VerdictDBException { BaseTable base = new BaseTable(originalSchema, originalTable, "t"); SelectQuery query = SelectQuery.create(Arrays.<SelectItem>asList(new AsteriskColumn()), base); QueryExecutionNode root = CreateTable...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public List<String> getTables(String schema) throws SQLException { if (!tablesCache.isEmpty()){ return tablesCache; } DbmsQueryResult queryResult = connection.executeQuery(syntax.getTableCommand(schema)); JdbcResultSet jdbcQueryResult = new JdbcResul...
#fixed code public List<String> getTables(String schema) throws SQLException { if (!tablesCache.isEmpty()){ return tablesCache; } tablesCache.addAll(connection.getTables(schema)); return tablesCache; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected Map<TableUniqueName, String> tableSubstitution() { return ImmutableMap.of(); } #location 2 #vulnerability type CHECKERS_IMMUTABLE_CAST
#fixed code @Override protected Map<TableUniqueName, String> tableSubstitution() { return source.tableSubstitution(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<String> getSchemas() throws VerdictDBDbmsException { List<String> schemas = new ArrayList<>(); DbmsQueryResult queryResult = execute(syntax.getSchemaCommand()); JdbcResultSet jdbcResultSet = new JdbcResultSet(queryResult); try { ...
#fixed code @Override public List<String> getSchemas() throws VerdictDBDbmsException { List<String> schemas = new ArrayList<>(); DbmsQueryResult queryResult = execute(syntax.getSchemaCommand()); while (queryResult.next()) { schemas.add((String) queryResult.getValue(synt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public List<String> getPartitionColumns(String schema, String table) throws SQLException { if (!syntax.doesSupportTablePartitioning()) { throw new SQLException("Database does not support table partitioning"); } if (!partitionCache.isEmpty()){ retur...
#fixed code public List<String> getPartitionColumns(String schema, String table) throws SQLException { if (!syntax.doesSupportTablePartitioning()) { throw new SQLException("Database does not support table partitioning"); } if (!partitionCache.isEmpty()){ return part...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public List<String> getSchemas() throws SQLException { if (!schemaCache.isEmpty()){ return schemaCache; } DbmsQueryResult queryResult = connection.executeQuery(syntax.getSchemaCommand()); JdbcResultSet jdbcQueryResult = new JdbcResultSet(queryResult)...
#fixed code public List<String> getSchemas() throws SQLException { if (!schemaCache.isEmpty()){ return schemaCache; } schemaCache.addAll(connection.getSchemas()); return schemaCache; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testSingleAggCombiningWithH2() throws VerdictDBDbmsException, VerdictDBException { QueryExecutionPlan plan = new QueryExecutionPlan("newschema"); BaseTable base = new BaseTable(originalSchema, originalTable, "t"); SelectQuery leftQuery...
#fixed code @Test public void testSingleAggCombiningWithH2() throws VerdictDBDbmsException, VerdictDBException { QueryExecutionPlan plan = new QueryExecutionPlan("newschema"); BaseTable base = new BaseTable(originalSchema, originalTable, "t"); SelectQuery leftQuery = Sel...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String visitSelect_list_elem(VerdictSQLParser.Select_list_elemContext ctx) { select_list_elem_num++; String newSelectListElem = null; Pair<String, Alias> colName2Alias = null; if (ctx.getText().equals("*")) { // TODO: replace * with all colu...
#fixed code @Override public String visitSelect_list_elem(VerdictSQLParser.Select_list_elemContext ctx) { select_list_elem_num++; String newSelectListElem = null; Pair<String, Alias> colName2Alias = null; if (ctx.getText().equals("*")) { // TODO: replace * with all columns in...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] a) throws Exception { PropertyConfigurator.configure(FoxCfg.LOG_FILE); String in = "University of Leipzig in Leipzig.."; String query = "select * from search.termextract where context="; URIBuilder buil...
#fixed code public static void main(String[] a) throws Exception { PropertyConfigurator.configure(FoxCfg.LOG_FILE); String in = "University of Leipzig in Leipzig.."; String query = "select * from search.termextract where context="; URIBuilder builder = ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Swagger read(Set<Class<?>> classes) throws GenerateException { //relate all methods to one base request mapping if multiple controllers exist for that mapping //get all methods from each controller & find their request mapping ...
#fixed code @Override public Swagger read(Set<Class<?>> classes) throws GenerateException { //relate all methods to one base request mapping if multiple controllers exist for that mapping //get all methods from each controller & find their request mapping //cr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected List<Parameter> getParameters(Type type, List<Annotation> annotations) { // look for path, query Iterator<SwaggerExtension> chain = SwaggerExtensions.chain(); List<Parameter> parameters = null; LOG.info("getParameters for " + t...
#fixed code protected List<Parameter> getParameters(Type type, List<Annotation> annotations) { Iterator<SwaggerExtension> chain = SwaggerExtensions.chain(); List<Parameter> parameters = new ArrayList<Parameter>(); LOG.info("Looking for path/query/header/form/cook...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void toDocuments() throws GenerateException { if (outputTemplate == null) { prepareMustacheTemplate(); } if (outputTemplate.getApiDocuments().isEmpty()) { LOG.warn("nothing to write."); return; }...
#fixed code public void toDocuments() throws GenerateException { if (outputTemplate == null) { prepareMustacheTemplate(); } if (outputTemplate.getApiDocuments().isEmpty()) { LOG.warn("nothing to write."); return; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Swagger read(SpringResource resource) { if (swagger == null) { swagger = new Swagger(); } List<Method> methods = resource.getMethods(); Map<String, Tag> tags = new HashMap<String, Tag>(); List<SecurityRequireme...
#fixed code public Swagger read(SpringResource resource) { if (swagger == null) { swagger = new Swagger(); } String description; List<Method> methods = resource.getMethods(); Map<String, Tag> tags = new HashMap<String, Tag>(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Map<String, List<Method>> collectApisByRequestMapping(List<Method> methods) { Map<String, List<Method>> apiMethodMap = new HashMap<String, List<Method>>(); for (Method method : methods) { if (method.isAnnotationPresent(RequestMapping....
#fixed code private Map<String, List<Method>> collectApisByRequestMapping(List<Method> methods) { Map<String, List<Method>> apiMethodMap = new HashMap<String, List<Method>>(); for (Method method : methods) { if (method.isAnnotationPresent(RequestMapping.class)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Operation parseMethod(String httpMethod, Method method) { int responseCode = 200; Operation operation = new Operation(); ApiOperation apiOperation = AnnotationUtils.findAnnotation(method, ApiOperation.class); String operationId = ...
#fixed code public Operation parseMethod(String httpMethod, Method method) { int responseCode = 200; Operation operation = new Operation(); ApiOperation apiOperation = AnnotationUtils.findAnnotation(method, ApiOperation.class); String operationId = getOpe...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Operation parseMethod(Method method) { Operation operation = new Operation(); RequestMapping requestMapping = Annotations.get(method, RequestMapping.class); Class<?> responseClass = null; List<String> produces = new ArrayList<Str...
#fixed code private Operation parseMethod(Method method) { Operation operation = new Operation(); RequestMapping requestMapping = AnnotationUtils.findAnnotation(method, RequestMapping.class); Class<?> responseClass = null; List<String> produces = new Arra...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGeneratedDoc() throws Exception { mojo.execute(); BufferedReader actualReader = null; BufferedReader expectReader = null; FileInputStream swaggerJson = null; BufferedReader swaggerReader = null; ...
#fixed code @Test public void testGeneratedDoc() throws Exception { mojo.execute(); FileInputStream swaggerJson = null; BufferedReader swaggerReader = null; try { File actual = docOutput; File expected = new File(this.getClass...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void toDocuments() throws GenerateException { if (outputTemplate == null) { prepareMustacheTemplate(); } if (outputTemplate.getApiDocuments().isEmpty()) { LOG.warn("nothing to write."); return; }...
#fixed code public void toDocuments() throws GenerateException { if (outputTemplate == null) { prepareMustacheTemplate(); } if (outputTemplate.getApiDocuments().isEmpty()) { LOG.warn("nothing to write."); return; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean stopUsingMysqldadmin() { boolean retValue = false; Reader stdOut = null; Reader stdErr = null; LogFileProcessor processor = null; Set<String> successPatterns = Sets.newHashSet( "'Can't connect to M...
#fixed code private boolean stopUsingMysqldadmin() { boolean retValue = false; Reader stdOut = null; Reader stdErr = null; LogFileProcessor processor = null; Set<String> successPatterns = Sets.newHashSet( "'Can't connect to MySQL s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void execute(final String sql) { String command = (Platform.detect() == Windows) ? format("\"%s\"", sql) : sql; try { Process p = Runtime.getRuntime().exec(new String[]{ Paths.get(executable.getBaseDir().getAbsolut...
#fixed code private void execute(final String sql) { String command = (Platform.detect() == Windows) ? format("\"%s\"", sql) : sql; try { Process p = new ProcessBuilder(new String[]{ Paths.get(executable.getBaseDir().getAbsolutePath(), "bin...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean stopUsingMysqldadmin() { boolean retValue = false; Reader stdOut = null; Reader stdErr = null; LogFileProcessor processor = null; Set<String> successPatterns = Sets.newHashSet("'Can't connect to MySQL server on 'l...
#fixed code private boolean stopUsingMysqldadmin() { boolean retValue = false; Reader stdOut = null; Reader stdErr = null; LogFileProcessor processor = null; Set<String> successPatterns = Sets.newHashSet( "'Can't connect to MySQL s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean stopUsingMysqldadmin() { boolean retValue = false; Reader stdOut = null; Reader stdErr = null; LogFileProcessor processor = null; Set<String> successPatterns = Sets.newHashSet( "'Can't connect to M...
#fixed code private boolean stopUsingMysqldadmin() { ResultMatchingListener shutdownListener = outputWatch.addListener(new ResultMatchingListener(": Shutdown complete")); boolean retValue = false; Reader stdErr = null; try { String cmd = Paths...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void execute(final String sql) { String command = (Platform.detect() == Windows) ? format("\"%s\"", sql) : sql; try { Process p = Runtime.getRuntime().exec(new String[]{ Paths.get(executable.getBaseDir().getAbsolut...
#fixed code private void execute(final String sql) { String command = (Platform.detect() == Windows) ? format("\"%s\"", sql) : sql; try { Process p = new ProcessBuilder(new String[]{ Paths.get(executable.getBaseDir().getAbsolutePath(), "bin...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void execute(final String sql) { String command = (Platform.detect() == Windows) ? format("\"%s\"", sql) : sql; try { Process p = Runtime.getRuntime().exec(new String[]{ Paths.get(executable.getBaseDir().getAbsolut...
#fixed code private void execute(final String sql) { String command = (Platform.detect() == Windows) ? format("\"%s\"", sql) : sql; try { Process p = new ProcessBuilder(new String[]{ Paths.get(executable.getBaseDir().getAbsolutePath(), "bin...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean stopUsingMysqldadmin() { boolean retValue = false; Reader stdOut = null; Reader stdErr = null; LogFileProcessor processor = null; Set<String> successPatterns = Sets.newHashSet("'Can't connect to MySQL server on 'l...
#fixed code private boolean stopUsingMysqldadmin() { boolean retValue = false; Reader stdOut = null; Reader stdErr = null; LogFileProcessor processor = null; Set<String> successPatterns = Sets.newHashSet( "'Can't connect to MySQL s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected SettableBeanProperty _resolvedObjectIdProperty(DeserializationContext ctxt, SettableBeanProperty prop) throws JsonMappingException { ObjectIdInfo objectIdInfo = prop.getObjectIdInfo(); JsonDeserializer<Object> valueDeser = prop....
#fixed code protected SettableBeanProperty _resolvedObjectIdProperty(DeserializationContext ctxt, SettableBeanProperty prop) throws JsonMappingException { ObjectIdInfo objectIdInfo = prop.getObjectIdInfo(); JsonDeserializer<Object> valueDeser = prop.getVal...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void runOnce() throws Exception { final ObjectMapper mapper = getObjectMapper(); Callable<String> writeJson = new Callable<String>() { @Override public String call() throws Exception { Wrapper wrapper = new Wrapper...
#fixed code void runOnce(int round, int max) throws Exception { final ObjectMapper mapper = getObjectMapper(); Callable<String> writeJson = new Callable<String>() { @Override public String call() throws Exception { Wrapper wrapper =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testDeepPrefixedUnwrappingDeserialize() throws Exception { DeepPrefixUnwrap bean = mapper.readValue("{\"u.name\":\"Bubba\",\"u._x\":2,\"u._y\":3}", DeepPrefixUnwrap.class); assertNotNull(bean.unwrapped); assertNotN...
#fixed code public void testDeepPrefixedUnwrappingDeserialize() throws Exception { DeepPrefixUnwrap bean = MAPPER.readValue("{\"u.name\":\"Bubba\",\"u._x\":2,\"u._y\":3}", DeepPrefixUnwrap.class); assertNotNull(bean.unwrapped); assertNotNull(be...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testHierarchicConfigRoundTrip() throws Exception { ConfigAlternate input = new ConfigAlternate(123, "Joe", 42); String json = mapper.writeValueAsString(input); ConfigAlternate root = mapper.readValue(json, ConfigAlternate.class);...
#fixed code public void testHierarchicConfigRoundTrip() throws Exception { ConfigAlternate input = new ConfigAlternate(123, "Joe", 42); String json = MAPPER.writeValueAsString(input); ConfigAlternate root = MAPPER.readValue(json, ConfigAlternate.class); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testBytestoCharArray() throws Exception { byte[] input = new byte[] { 1, 2, 3, 4, 5, 6, 7 }; // first, do baseline encoding char[] expEncoded = mapper.convertValue(input, String.class).toCharArray(); // then compare ...
#fixed code public void testBytestoCharArray() throws Exception { byte[] input = new byte[] { 1, 2, 3, 4, 5, 6, 7 }; // first, do baseline encoding char[] expEncoded = MAPPER.convertValue(input, String.class).toCharArray(); // then compare char...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testSimpleMapImitation() throws Exception { MapImitator mapHolder = MAPPER.readValue ("{ \"a\" : 3, \"b\" : true }", MapImitator.class); Map<String,Object> result = mapHolder._map; assertEquals(2, result.size()); ...
#fixed code public void testSimpleMapImitation() throws Exception { MapImitator mapHolder = MAPPER.readValue ("{ \"a\" : 3, \"b\" : true, \"c\":[1,2,3] }", MapImitator.class); Map<String,Object> result = mapHolder._map; assertEquals(3, result.size(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testHierarchicConfigDeserialize() throws Exception { ConfigRoot root = mapper.readValue("{\"general.names.name\":\"Bob\",\"misc.value\":3}", ConfigRoot.class); assertNotNull(root.general); assertNotNull(root.genera...
#fixed code public void testHierarchicConfigDeserialize() throws Exception { ConfigRoot root = MAPPER.readValue("{\"general.names.name\":\"Bob\",\"misc.value\":3}", ConfigRoot.class); assertNotNull(root.general); assertNotNull(root.general.name...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testAtomicReference() throws Exception { ObjectMapper mapper = new ObjectMapper(); AtomicReference<long[]> value = mapper.readValue("[1,2]", new com.fasterxml.jackson.core.type.TypeReference<AtomicReference<long[]>>() { })...
#fixed code public void testAtomicReference() throws Exception { AtomicReference<long[]> value = MAPPER.readValue("[1,2]", new com.fasterxml.jackson.core.type.TypeReference<AtomicReference<long[]>>() { }); Object ob = value.get(); assertNotNull...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <T> MappingIterator<T> readValues(File src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { return _detectBindAndReadValues( _dataFormatReaders.findFormat(_inputStream(src)), fals...
#fixed code public <T> MappingIterator<T> readValues(File src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { return _detectBindAndReadValues( _dataFormatReaders.findFormat(_inputStream(src)), false); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testRootBeans() throws Exception { final String JSON = aposToQuotes("{'a':3} {'b':5}"); MappingIterator<Bean> it = MAPPER.readerFor(Bean.class).readValues(JSON); // First one should be fine assertTrue(it.hasNextValue()); ...
#fixed code public void testRootBeans() throws Exception { final String JSON = aposToQuotes("{'a':3} {'x':5}"); MappingIterator<Bean> it = MAPPER.readerFor(Bean.class).readValues(JSON); // First one should be fine assertTrue(it.hasNextValue()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("resource") public <T> MappingIterator<T> readValues(Reader src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { _reportUndetectableSource(src); } JsonParser p = consid...
#fixed code @SuppressWarnings("resource") public <T> MappingIterator<T> readValues(Reader src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { _reportUndetectableSource(src); } JsonParser p = _considerFil...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testAtomicBoolean() throws Exception { ObjectMapper mapper = new ObjectMapper(); AtomicBoolean b = mapper.readValue("true", AtomicBoolean.class); assertTrue(b.get()); } #location 5 ...
#fixed code public void testAtomicBoolean() throws Exception { AtomicBoolean b = MAPPER.readValue("true", AtomicBoolean.class); assertTrue(b.get()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public PropertyMetadata getMetadata() { final Boolean b = _findRequired(); final String desc = _findDescription(); final Integer idx = _findIndex(); final String def = _findDefaultValue(); if (b == null && idx == nul...
#fixed code @Override public PropertyMetadata getMetadata() { final Boolean b = _findRequired(); final String desc = _findDescription(); final Integer idx = _findIndex(); final String def = _findDefaultValue(); if (b == null && idx == null && d...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String idFromValue(Object value) { Class<?> cls = _typeFactory.constructType(value.getClass()).getRawClass(); final String key = cls.getName(); String name; synchronized (_typeToId) { name = _typeToId....
#fixed code @Override public String idFromValue(Object value) { return idFromClass(value.getClass()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <T> MappingIterator<T> readValues(byte[] src, int offset, int length) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { return _detectBindAndReadValues(_dataFormatReaders.findFormat(src, offset, length...
#fixed code public <T> MappingIterator<T> readValues(byte[] src, int offset, int length) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { return _detectBindAndReadValues(_dataFormatReaders.findFormat(src, offset, length), fal...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testAtomicLong() throws Exception { ObjectMapper mapper = new ObjectMapper(); AtomicLong value = mapper.readValue("12345678901", AtomicLong.class); assertEquals(12345678901L, value.get()); } #locat...
#fixed code public void testAtomicLong() throws Exception { AtomicLong value = MAPPER.readValue("12345678901", AtomicLong.class); assertEquals(12345678901L, value.get()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testMapUnwrapDeserialize() throws Exception { MapUnwrap root = mapper.readValue("{\"map.test\": 6}", MapUnwrap.class); assertEquals(1, root.map.size()); assertEquals(6, ((Number)root.map.get("test")).intValue()); } ...
#fixed code public void testMapUnwrapDeserialize() throws Exception { MapUnwrap root = MAPPER.readValue("{\"map.test\": 6}", MapUnwrap.class); assertEquals(1, root.map.size()); assertEquals(6, ((Number)root.map.get("test")).intValue()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void withTree749() throws Exception { Map<KeyEnum, Object> inputMap = new LinkedHashMap<KeyEnum, Object>(); Map<TestEnum, Map<String, String>> replacements = new LinkedHashMap<TestEnum, Map<String, String>>(); Map<String, String> reps ...
#fixed code public void withTree749() throws Exception { ObjectMapper mapper = new ObjectMapper().registerModule(new TestEnumModule()); Map<KeyEnum, Object> inputMap = new LinkedHashMap<KeyEnum, Object>(); Map<TestEnum, Map<String, String>> replacements = new...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <T> MappingIterator<T> readValues(InputStream src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { return _detectBindAndReadValues(_dataFormatReaders.findFormat(src), false); } ...
#fixed code public <T> MappingIterator<T> readValues(InputStream src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { return _detectBindAndReadValues(_dataFormatReaders.findFormat(src), false); } ret...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testAtomicInt() throws Exception { ObjectMapper mapper = new ObjectMapper(); AtomicInteger value = mapper.readValue("13", AtomicInteger.class); assertEquals(13, value.get()); } #location 5 ...
#fixed code public void testAtomicInt() throws Exception { AtomicInteger value = MAPPER.readValue("13", AtomicInteger.class); assertEquals(13, value.get()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <T> MappingIterator<T> readValues(URL src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { return _detectBindAndReadValues( _dataFormatReaders.findFormat(_inputStream(src)), true)...
#fixed code public <T> MappingIterator<T> readValues(URL src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { return _detectBindAndReadValues( _dataFormatReaders.findFormat(_inputStream(src)), true); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testPrefixedUnwrapping() throws Exception { PrefixUnwrap bean = mapper.readValue("{\"name\":\"Axel\",\"_x\":4,\"_y\":7}", PrefixUnwrap.class); assertNotNull(bean); assertEquals("Axel", bean.name); assertNotNull(bean.locati...
#fixed code public void testPrefixedUnwrapping() throws Exception { PrefixUnwrap bean = MAPPER.readValue("{\"name\":\"Axel\",\"_x\":4,\"_y\":7}", PrefixUnwrap.class); assertNotNull(bean); assertEquals("Axel", bean.name); assertNotNull(bean.location); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected SiteMap processText(String sitemapUrl, byte[] content) throws IOException { LOG.debug("Processing textual Sitemap"); SiteMap textSiteMap = new SiteMap(sitemapUrl); textSiteMap.setType(SitemapType.TEXT); BOMInputStream bomIs = ...
#fixed code protected SiteMap processText(String sitemapUrl, byte[] content) throws IOException { LOG.debug("Processing textual Sitemap"); SiteMap textSiteMap = new SiteMap(sitemapUrl); textSiteMap.setType(SitemapType.TEXT); BOMInputStream bomIs = new BO...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private AbstractSiteMap processXml(URL sitemapUrl, byte[] xmlContent) throws UnknownFormatException { BOMInputStream bomIs = new BOMInputStream(new ByteArrayInputStream(xmlContent)); InputSource is = new InputSource(); is.setCharacterStream(new ...
#fixed code private AbstractSiteMap processXml(URL sitemapUrl, byte[] xmlContent) throws UnknownFormatException { BOMInputStream bomIs = new BOMInputStream(new ByteArrayInputStream(xmlContent)); InputSource is = new InputSource(); try { is.setCharacte...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testVideosSitemap() throws UnknownFormatException, IOException { SiteMapParser parser = new SiteMapParser(); parser.enableExtension(Extension.VIDEO); String contentType = "text/xml"; byte[] content = SiteMapParserTe...
#fixed code @Test public void testVideosSitemap() throws UnknownFormatException, IOException { SiteMapParser parser = new SiteMapParser(); parser.enableExtension(Extension.VIDEO); String contentType = "text/xml"; byte[] content = SiteMapParserTest.get...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected AbstractSiteMap processXml(URL sitemapUrl, byte[] xmlContent) throws UnknownFormatException { BOMInputStream bomIs = new BOMInputStream(new ByteArrayInputStream(xmlContent)); InputSource is = new InputSource(); try { is.set...
#fixed code protected AbstractSiteMap processXml(URL sitemapUrl, byte[] xmlContent) throws UnknownFormatException { BOMInputStream bomIs = new BOMInputStream(new ByteArrayInputStream(xmlContent)); InputSource is = new InputSource(); is.setCharacterStream(new Buff...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean validate(UserPersonalInfo info) { validator.validate(info); if(validator.hasErrors()){ return false; } if (info.getUser() == null) { validator.add(new ValidationMessage("user.errors.wrong", "error")); } if(!info.getUser().get...
#fixed code public boolean validate(UserPersonalInfo info) { validator.validate(info); if(validator.hasErrors()){ return false; } if (info.getUser() == null) { validator.add(new ValidationMessage("user.errors.wrong", "error")); } if (!info.getUser().getEmail...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void moderator_should_approve_question_information() throws Exception { Question question = question("question title", "question description", author); Information approvedInfo = new QuestionInformation("edited title", "edited desc", ...
#fixed code @Test public void moderator_should_approve_question_information() throws Exception { Information approvedInfo = new QuestionInformation("edited title", "edited desc", new LoggedUser(otherUser, null), new ArrayList<Tag>(), "comment"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean validate(UserPersonalInfo info) { validator.validate(info); if (info.getUser() == null) { validator.add(new ValidationMessage("error","user.errors.wrong")); } if(!info.getUser().getName().equals(info.getName())){ userNameValidator.v...
#fixed code public boolean validate(UserPersonalInfo info) { validator.validate(info); if (info.getUser() == null) { validator.add(new ValidationMessage("user.errors.wrong", "error")); } if(!info.getUser().getName().equals(info.getName())){ userNameValidator.valida...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testAlternateDefaultEncoding(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String alternateEnc) throws Exception { try { final InputStream is; if (prologEnc == null) { ...
#fixed code public void testAlternateDefaultEncoding(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String alternateEnc) throws Exception { XmlReader xmlReader = null; try { final InputStream is; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void testRawNoBomValid(final String encoding) throws Exception { InputStream is = getXmlStream("no-bom", XML1, encoding, encoding); XmlReader xmlReader = new XmlReader(is, false); assertEquals(xmlReader.getEncoding(), "UTF-8"); ...
#fixed code protected void testRawNoBomValid(final String encoding) throws Exception { checkEncoding(XML1, encoding, "UTF-8"); checkEncoding(XML2, encoding, "UTF-8"); checkEncoding(XML3, encoding, encoding); checkEncoding(XML4, encoding, encoding); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void testRawNoBomValid(final String encoding) throws Exception { InputStream is = getXmlStream("no-bom", XML1, encoding, encoding); XmlReader xmlReader = new XmlReader(is, false); assertEquals(xmlReader.getEncoding(), "UTF-8"); ...
#fixed code protected void testRawNoBomValid(final String encoding) throws Exception { checkEncoding(XML1, encoding, "UTF-8"); checkEncoding(XML2, encoding, "UTF-8"); checkEncoding(XML3, encoding, encoding); checkEncoding(XML4, encoding, encoding); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static Date parseUsingMask(final String[] masks, String sDate) { sDate = sDate != null ? sDate.trim() : null; ParsePosition pp = null; Date d = null; for (int i = 0; d == null && i < masks.length; i++) { final DateForm...
#fixed code private static Date parseUsingMask(final String[] masks, String sDate) { if (sDate != null) { sDate = sDate.trim(); } ParsePosition pp = null; Date d = null; for (int i = 0; d == null && i < masks.length; i++) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testAlternateDefaultEncoding(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String alternateEnc) throws Exception { try { final InputStream is; if (prologEnc == null) { ...
#fixed code public void testAlternateDefaultEncoding(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String alternateEnc) throws Exception { XmlReader xmlReader = null; try { final InputStream is; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void testRawNoBomValid(final String encoding) throws Exception { InputStream is = getXmlStream("no-bom", XML1, encoding, encoding); XmlReader xmlReader = new XmlReader(is, false); assertEquals(xmlReader.getEncoding(), "UTF-8"); ...
#fixed code protected void testRawNoBomValid(final String encoding) throws Exception { checkEncoding(XML1, encoding, "UTF-8"); checkEncoding(XML2, encoding, "UTF-8"); checkEncoding(XML3, encoding, encoding); checkEncoding(XML4, encoding, encoding); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void testRawBomInvalid(final String bomEnc, final String streamEnc, final String prologEnc) throws Exception { final InputStream is = getXmlStream(bomEnc, XML3, streamEnc, prologEnc); try { final XmlReader xmlReader = new XmlReader(...
#fixed code protected void testRawBomInvalid(final String bomEnc, final String streamEnc, final String prologEnc) throws Exception { final InputStream is = getXmlStream(bomEnc, XML3, streamEnc, prologEnc); try { final XmlReader xmlReader = new XmlReader(is, fa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public SyndFeedInfo remove(final URL url) { SyndFeedInfo info = null; final String fileName = cachePath + File.separator + "feed_" + replaceNonAlphanumeric(url.toString(), '_').trim(); FileInputStream fis; try { ...
#fixed code @Override public SyndFeedInfo remove(final URL url) { SyndFeedInfo info = null; final String fileName = cachePath + File.separator + "feed_" + replaceNonAlphanumeric(url.toString(), '_').trim(); FileInputStream fis = null; ObjectInputStream...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testHttpValid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception { final InputStream is; if (prologEnc == null) { is = getXmlStream(bomEnc, XML1, streamEnc, prologEnc); }...
#fixed code public void testHttpValid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception { final InputStream is; if (prologEnc == null) { is = getXmlStream(bomEnc, XML1, streamEnc, prologEnc); } else ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testEncodingAttributeXML() throws Exception { final InputStream is = new ByteArrayInputStream(ENCODING_ATTRIBUTE_XML.getBytes()); final XmlReader xmlReader = new XmlReader(is, "", true); assertEquals(xmlReader.getEncoding(), "UTF-8");...
#fixed code public void testEncodingAttributeXML() throws Exception { final InputStream is = new ByteArrayInputStream(ENCODING_ATTRIBUTE_XML.getBytes()); final XmlReader xmlReader = new XmlReader(is, "", true); assertEquals(xmlReader.getEncoding(), "UTF-8"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void testRawNoBomInvalid(final String encoding) throws Exception { final InputStream is = getXmlStream("no-bom", XML3, encoding, encoding); try { final XmlReader xmlReader = new XmlReader(is, false); fail("It should have...
#fixed code protected void testRawNoBomInvalid(final String encoding) throws Exception { InputStream is = null; XmlReader xmlReader = null; try { is = getXmlStream("no-bom", XML3, encoding, encoding); xmlReader = new XmlReader(is, false); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testHttpValid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception { final InputStream is; if (prologEnc == null) { is = getXmlStream(bomEnc, XML1, streamEnc, prologEnc); }...
#fixed code public void testHttpValid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception { final InputStream is; if (prologEnc == null) { is = getXmlStream(bomEnc, XML1, streamEnc, prologEnc); } else ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public SyndFeedInfo getFeedInfo(final URL url) { SyndFeedInfo info = null; final String fileName = cachePath + File.separator + "feed_" + replaceNonAlphanumeric(url.toString(), '_').trim(); FileInputStream fis; try { ...
#fixed code @Override public SyndFeedInfo getFeedInfo(final URL url) { SyndFeedInfo info = null; final String fileName = cachePath + File.separator + "feed_" + replaceNonAlphanumeric(url.toString(), '_').trim(); FileInputStream fis = null; ObjectInputS...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void testRawBomValid(final String encoding) throws Exception { final InputStream is = getXmlStream(encoding + "-bom", XML3, encoding, encoding); final XmlReader xmlReader = new XmlReader(is, false); if (!encoding.equals("UTF-16")) { ...
#fixed code protected void testRawBomValid(final String encoding) throws Exception { final InputStream is = getXmlStream(encoding + "-bom", XML3, encoding, encoding); final XmlReader xmlReader = new XmlReader(is, false); if (!encoding.equals("UTF-16")) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void testRawNoBomValid(final String encoding) throws Exception { InputStream is = getXmlStream("no-bom", XML1, encoding, encoding); XmlReader xmlReader = new XmlReader(is, false); assertEquals(xmlReader.getEncoding(), "UTF-8"); ...
#fixed code protected void testRawNoBomValid(final String encoding) throws Exception { checkEncoding(XML1, encoding, "UTF-8"); checkEncoding(XML2, encoding, "UTF-8"); checkEncoding(XML3, encoding, encoding); checkEncoding(XML4, encoding, encoding); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testParse() { final Calendar cal = new GregorianCalendar(); cal.setTimeZone(TimeZone.getTimeZone("GMT")); // four-digit year String sDate = "Tue, 19 Jul 2005 23:00:51 GMT"; cal.setTime(DateParser.parseRFC822(sDate)); ...
#fixed code public void testParse() { final Calendar cal = new GregorianCalendar(); cal.setTimeZone(TimeZone.getTimeZone("GMT")); // four-digit year String sDate = "Tue, 19 Jul 2005 23:00:51 GMT"; cal.setTime(DateParser.parseRFC822(sDate, Locale.U...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void testHttpLenient(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String shouldbe) throws Exception { final InputStream is; if (prologEnc == null) { is = getXmlStream(bomEnc...
#fixed code protected void testHttpLenient(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String shouldbe) throws Exception { final InputStream is; if (prologEnc == null) { is = getXmlStream(bomEnc, XML2...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void testRawBomValid(final String encoding) throws Exception { final InputStream is = getXmlStream(encoding + "-bom", XML3, encoding, encoding); final XmlReader xmlReader = new XmlReader(is, false); if (!encoding.equals("UTF-16")) { ...
#fixed code protected void testRawBomValid(final String encoding) throws Exception { final InputStream is = getXmlStream(encoding + "-bom", XML3, encoding, encoding); final XmlReader xmlReader = new XmlReader(is, false); if (!encoding.equals("UTF-16")) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testParse() { final Calendar cal = new GregorianCalendar(); cal.setTimeZone(TimeZone.getTimeZone("GMT")); // four-digit year String sDate = "Tue, 19 Jul 2005 23:00:51 GMT"; cal.setTime(DateParser.parseRFC822(sDate)); ...
#fixed code public void testParse() { final Calendar cal = new GregorianCalendar(); cal.setTimeZone(TimeZone.getTimeZone("GMT")); // four-digit year String sDate = "Tue, 19 Jul 2005 23:00:51 GMT"; cal.setTime(DateParser.parseRFC822(sDate, Locale.U...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void testRawNoBomValid(final String encoding) throws Exception { InputStream is = getXmlStream("no-bom", XML1, encoding, encoding); XmlReader xmlReader = new XmlReader(is, false); assertEquals(xmlReader.getEncoding(), "UTF-8"); ...
#fixed code protected void testRawNoBomValid(final String encoding) throws Exception { checkEncoding(XML1, encoding, "UTF-8"); checkEncoding(XML2, encoding, "UTF-8"); checkEncoding(XML3, encoding, encoding); checkEncoding(XML4, encoding, encoding); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code Element pop() { // todo - dev, remove validation check if (stack.peekLast().nodeName().equals("td") && !state.name().equals("InCell")) Validate.isFalse(true, "pop td not in cell"); if (stack.peekLast().nodeName().equals("html")) ...
#fixed code HtmlTreeBuilder() {}
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static String readInputStream(InputStream inStream, String charsetName) throws IOException { char[] buffer = new char[0x20000]; // ~ 130K StringBuilder data = new StringBuilder(0x20000); Reader inReader = new InputStreamReader(inStream, c...
#fixed code private static String readInputStream(InputStream inStream, String charsetName) throws IOException { byte[] buffer = new byte[bufferSize]; ByteArrayOutputStream outStream = new ByteArrayOutputStream(bufferSize); int read; while(true) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static String load(File in, String charsetName) throws IOException { char[] buffer = new char[0x20000]; // ~ 130K StringBuilder data = new StringBuilder(0x20000); InputStream inStream = new FileInputStream(in); Reader inReader = n...
#fixed code static String load(File in, String charsetName) throws IOException { InputStream inStream = new FileInputStream(in); String data = readInputStream(inStream, charsetName); inStream.close(); return data; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Document normalise() { if (select("html").isEmpty()) appendElement("html"); if (head() == null) select("html").first().prependElement("head"); if (body() == null) select("html").first().appendElement("bo...
#fixed code public Document normalise() { if (select("html").isEmpty()) appendElement("html"); if (head() == null) select("html").first().prependElement("head"); if (body() == null) select("html").first().appendElement("body"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Document parse() { // TODO: figure out implicit head & body elements Document doc = new Document(); stack.add(doc); while (tokenStream.hasNext()) { Token token = tokenStream.next(); if (token.isStartTag())...
#fixed code public Document parse() { // TODO: figure out implicit head & body elements Document doc = new Document(); stack.add(doc); StringBuilder commentAccum = null; while (tokenStream.hasNext()) { Token token = tokenStream.next()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Node previousSibling() { List<Node> siblings = parentNode.childNodes; Integer index = indexInList(this, siblings); Validate.notNull(index); if (index > 0) return siblings.get(index-1); else return nu...
#fixed code public Node previousSibling() { List<Node> siblings = parentNode.childNodes; Integer index = siblingIndex(); Validate.notNull(index); if (index > 0) return siblings.get(index-1); else return null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void insert(Token.Character characterToken) { Node node; // characters in script and style go in as datanodes, not text nodes final String tagName = currentElement().tagName(); final String data = characterToken.getData(); if (ch...
#fixed code ParseSettings defaultSettings() { return ParseSettings.htmlDefault; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testPreviousElementSiblings() { Document doc = Jsoup.parse("<li id='a'>a</li>" + "<li id='b'>b</li>" + "<li id='c'>c</li>"); Element element = doc.getElementById("b"); List<Element> elementSiblings = ...
#fixed code @Test public void testPreviousElementSiblings() { Document doc = Jsoup.parse("<ul id='ul'>" + "<li id='a'>a</li>" + "<li id='b'>b</li>" + "<li id='c'>c</li>" + "</ul>" + "<div id='div'>" + "<l...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void forms() { Document doc = Jsoup.parse("<form id=1><input name=q></form><div /><form id=2><input name=f></form>"); Elements els = doc.select("*"); assertEquals(9, els.size()); List<FormElement> forms = els.forms(); ...
#fixed code @Test public void forms() { Document doc = Jsoup.parse("<form id=1><input name=q></form><div /><form id=2><input name=f></form>"); Elements els = doc.select("*"); assertEquals(9, els.size()); List<FormElement> forms = els.forms(); asse...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static String load(File in, String charsetName) throws IOException { char[] buffer = new char[0x20000]; // ~ 130K StringBuilder data = new StringBuilder(0x20000); InputStream inStream = new FileInputStream(in); Reader inReader = n...
#fixed code static String load(File in, String charsetName) throws IOException { InputStream inStream = new FileInputStream(in); String data = readInputStream(inStream, charsetName); inStream.close(); return data; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Node nextSibling() { if (parentNode == null) return null; // root List<Node> siblings = parentNode.childNodes; Integer index = indexInList(this, siblings); Validate.notNull(index); if (siblings.size() >...
#fixed code public Node nextSibling() { if (parentNode == null) return null; // root List<Node> siblings = parentNode.childNodes; Integer index = siblingIndex(); Validate.notNull(index); if (siblings.size() > index+1) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Document normalise() { if (select("html").isEmpty()) appendElement("html"); if (head() == null) select("html").first().prependElement("head"); if (body() == null) select("html").first().appendElement("bo...
#fixed code public Document normalise() { Element htmlEl = findFirstElementByTagName("html", this); if (htmlEl == null) htmlEl = appendElement("html"); if (head() == null) htmlEl.prependElement("head"); if (body() == null) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void insert(Token.Character characterToken) { Node node; // characters in script and style go in as datanodes, not text nodes final String tagName = currentElement().tagName(); final String data = characterToken.getData(); if (ch...
#fixed code ParseSettings defaultSettings() { return ParseSettings.htmlDefault; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean matchesWhitespace() { return !isEmpty() && Character.isWhitespace(peek()); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public boolean matchesWhitespace() { return !isEmpty() && Character.isWhitespace(queue.charAt(pos)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testAppendTo() { String parentHtml = "<div class='a'></div>"; String childHtml = "<div class='b'></div>"; Element parentElement = Jsoup.parse(parentHtml).getElementsByClass("a").first(); Element childElement = Jsoup.parse(childHtml).getElementsB...
#fixed code @Test public void testAppendTo() { String parentHtml = "<div class='a'></div>"; String childHtml = "<div class='b'></div><p>Two</p>"; Document parentDoc = Jsoup.parse(parentHtml); Element parent = parentDoc.body(); Document childDoc = Jsoup.parse(childHtml); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code Element pop() { // todo - dev, remove validation check if (stack.peekLast().nodeName().equals("td") && !state.name().equals("InCell")) Validate.isFalse(true, "pop td not in cell"); if (stack.peekLast().nodeName().equals("html")) ...
#fixed code HtmlTreeBuilder() {}
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Document normalise() { if (select("html").isEmpty()) appendElement("html"); if (head() == null) select("html").first().prependElement("head"); if (body() == null) select("html").first().appendElement("bo...
#fixed code public Document normalise() { Element htmlEl = findFirstElementByTagName("html", this); if (htmlEl == null) htmlEl = appendElement("html"); if (head() == null) htmlEl.prependElement("head"); if (body() == null) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void outerHtmlHead(StringBuilder accum, int depth) { if (isBlock() || (parent() != null && parent().tag().canContainBlock() && siblingIndex() == 0)) indent(accum, depth); accum .append("<") .append(tagName()) ...
#fixed code boolean preserveWhitespace() { return tag.preserveWhitespace() || parent() != null && parent().preserveWhitespace(); }
Below is the vulnerable code, please generate the patch based on the following information.