Reconfigurable intelligent surface (RIS) makes it possible to create an intelligent electromagnetic environment. The low hardware cost makes ultra-large (XL) RIS an attractive performance enhancement scheme, but it brings the challenge of near-field propagation channels. This makes the localization and channel estimation more complicated. In this paper, we consider the spherical wavefront propagation in the near field of the millimeter-wave/sub-Terahertz (mmWave/subTHz) localization system with the assistance of a RIS. A near-field joint channel estimation and localization (NF-JCEL) algorithm is proposed based on the derived second-order Fresnel approximation of the near-field channel model. To be specific, we first decouple the user equipment (UE) distances and angles of arrival (AoAs) through a down-sampled Toeplitz covariance matrix, so that the vertical and azimuth AoAs in the array steering vectors can be estimated separately with low complexities. Then, the UE distance can be estimated by the simple one-dimensional search, and the channel attenuation coefficients are obtained through the orthogonal matching pursuit (OMP) method. Simulation results validate the superiority of the proposed NF-JCEL algorithm to the conventional far-field algorithm, and show that higher resolution accuracy can be obtained by the proposed algorithm.